Skip to content

Commit

Permalink
Break down resolve functions for compression settings
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Dec 12, 2023
1 parent 4e209ff commit d301d6b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 37 deletions.
9 changes: 8 additions & 1 deletion aws-runtime/aws-config/api/aws-config.api
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ public final class aws/sdk/kotlin/runtime/config/compression/CompressionSettings
public final fun getAwsRequestMinCompressionSizeBytes ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
}

public final class aws/sdk/kotlin/runtime/config/compression/ResolveRequestCompressionKt {
public final class aws/sdk/kotlin/runtime/config/compression/ResolveDisableRequestCompressionKt {
public static final fun resolveDisableRequestCompression (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun resolveDisableRequestCompression$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}

public final class aws/sdk/kotlin/runtime/config/compression/ResolveRequestMinCompressionSizeBytesKt {
public static final fun resolveRequestMinCompressionSizeBytes (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun resolveRequestMinCompressionSizeBytes$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}

public final class aws/sdk/kotlin/runtime/config/endpoints/AccountIdEndpointMode : java/lang/Enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
package aws.sdk.kotlin.runtime.config

import aws.sdk.kotlin.runtime.client.AwsSdkClientConfig
import aws.sdk.kotlin.runtime.config.compression.resolveRequestCompression
import aws.sdk.kotlin.runtime.config.compression.resolveDisableRequestCompression
import aws.sdk.kotlin.runtime.config.compression.resolveRequestMinCompressionSizeBytes
import aws.sdk.kotlin.runtime.config.endpoints.resolveUseDualStack
import aws.sdk.kotlin.runtime.config.endpoints.resolveUseFips
import aws.sdk.kotlin.runtime.config.profile.AwsProfile
Expand Down Expand Up @@ -80,7 +81,13 @@ public abstract class AbstractAwsSdkClientFactory<
config.applicationId = config.applicationId ?: resolveUserAgentAppId(platform, profile)

if (config is CompressionClientConfig.Builder) {
config.requestCompression = resolveRequestCompression(platform, profile)
config.requestCompression.disableRequestCompression =
config.requestCompression.disableRequestCompression
?: resolveDisableRequestCompression(platform, profile)

config.requestCompression.requestMinCompressionSizeBytes =
config.requestCompression.requestMinCompressionSizeBytes
?: resolveRequestMinCompressionSizeBytes(platform, profile)
}

finalizeConfig(builder, sharedConfig, profile)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.runtime.config.compression

import aws.sdk.kotlin.runtime.config.profile.AwsProfile
import aws.sdk.kotlin.runtime.config.profile.disableRequestCompression
import aws.smithy.kotlin.runtime.InternalApi
import aws.smithy.kotlin.runtime.config.resolve
import aws.smithy.kotlin.runtime.util.LazyAsyncValue
import aws.smithy.kotlin.runtime.util.PlatformProvider

/**
* Attempts to resolve disableRequestCompression from the specified sources.
* @return disableRequestCompression setting if found, the default value if not.
*/
@InternalApi
public suspend fun resolveDisableRequestCompression(
platform: PlatformProvider = PlatformProvider.System,
profile: LazyAsyncValue<AwsProfile>,
): Boolean =
CompressionSettings.AwsDisableRequestCompression.resolve(platform)
?: profile.get().disableRequestCompression
?: false

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.runtime.config.compression

import aws.sdk.kotlin.runtime.config.profile.AwsProfile
import aws.sdk.kotlin.runtime.config.profile.requestMinCompressionSizeBytes
import aws.smithy.kotlin.runtime.InternalApi
import aws.smithy.kotlin.runtime.config.resolve
import aws.smithy.kotlin.runtime.util.LazyAsyncValue
import aws.smithy.kotlin.runtime.util.PlatformProvider

/**
* Attempts to resolve requestMinCompressionSizeBytes from the specified sources.
* @return requestMinCompressionSizeBytes setting if found, the default value if not.
*/
@InternalApi
public suspend fun resolveRequestMinCompressionSizeBytes(
platform: PlatformProvider = PlatformProvider.System,
profile: LazyAsyncValue<AwsProfile>,
): Long =
CompressionSettings.AwsRequestMinCompressionSizeBytes.resolve(platform)
?: profile.get().requestMinCompressionSizeBytes
?: 10240

0 comments on commit d301d6b

Please sign in to comment.