forked from smithy-lang/smithy-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: apply clock skew interceptor (smithy-lang#1065)
- Loading branch information
Showing
3 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/ClockSkew.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.sdk.kotlin.codegen.customization | ||
|
||
import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes | ||
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration | ||
import software.amazon.smithy.kotlin.codegen.integration.SectionWriter | ||
import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding | ||
import software.amazon.smithy.kotlin.codegen.rendering.ServiceClientGenerator | ||
|
||
/** | ||
* Adds a section writer which applies an interceptor that detects and corrects clock skew | ||
*/ | ||
class ClockSkew : KotlinIntegration { | ||
override val sectionWriters: List<SectionWriterBinding> | ||
get() = listOf(SectionWriterBinding(ServiceClientGenerator.Sections.FinalizeConfig, clockSkewSectionWriter)) | ||
|
||
private val clockSkewSectionWriter = SectionWriter { writer, _ -> | ||
val interceptorSymbol = RuntimeTypes.AwsProtocolCore.ClockSkewInterceptor | ||
writer.write("builder.config.interceptors.add(0, #T())", interceptorSymbol) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters