commonMain.aws.sdk.kotlin.services.signer.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signer-jvm Show documentation
Show all versions of signer-jvm Show documentation
The AWS SDK for Kotlin client for signer
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.signer.waiters
import aws.sdk.kotlin.services.signer.SignerClient
import aws.sdk.kotlin.services.signer.model.DescribeSigningJobRequest
import aws.sdk.kotlin.services.signer.model.DescribeSigningJobResponse
import aws.smithy.kotlin.runtime.retries.Outcome
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategyOptions
import aws.smithy.kotlin.runtime.retries.delay.ExponentialBackoffWithJitter
import aws.smithy.kotlin.runtime.retries.delay.ExponentialBackoffWithJitterOptions
import aws.smithy.kotlin.runtime.retries.delay.InfiniteTokenBucket
import aws.smithy.kotlin.runtime.retries.policy.Acceptor
import aws.smithy.kotlin.runtime.retries.policy.AcceptorRetryPolicy
import aws.smithy.kotlin.runtime.retries.policy.ErrorTypeAcceptor
import aws.smithy.kotlin.runtime.retries.policy.OutputAcceptor
import aws.smithy.kotlin.runtime.retries.policy.RetryDirective
import kotlin.time.Duration.Companion.milliseconds
suspend fun SignerClient.waitUntilSuccessfulSigningJob(request: DescribeSigningJobRequest): Outcome {
val strategy = run {
val delayOptions = ExponentialBackoffWithJitterOptions(
initialDelay = 20_000.milliseconds,
scaleFactor = 1.5,
jitter = 1.0,
maxBackoff = 120_000.milliseconds,
)
val delay = ExponentialBackoffWithJitter(delayOptions)
val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it?.status
status?.toString() == "Succeeded"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val status = it?.status
status?.toString() == "Failed"
},
ErrorTypeAcceptor(RetryDirective.TerminateAndFail, "ResourceNotFoundException"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeSigningJob(request) }
}
suspend fun SignerClient.waitUntilSuccessfulSigningJob(block: DescribeSigningJobRequest.Builder.() -> Unit): Outcome =
waitUntilSuccessfulSigningJob(DescribeSigningJobRequest.Builder().apply(block).build())
© 2015 - 2025 Weber Informatics LLC | Privacy Policy