commonMain.aws.sdk.kotlin.services.codedeploy.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codedeploy-jvm Show documentation
Show all versions of codedeploy-jvm Show documentation
The AWS SDK for Kotlin client for CodeDeploy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.codedeploy.waiters
import aws.sdk.kotlin.services.codedeploy.CodeDeployClient
import aws.sdk.kotlin.services.codedeploy.model.GetDeploymentRequest
import aws.sdk.kotlin.services.codedeploy.model.GetDeploymentResponse
import aws.smithy.kotlin.runtime.retries.Outcome
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy
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.OutputAcceptor
import aws.smithy.kotlin.runtime.retries.policy.RetryDirective
import kotlin.time.Duration.Companion.milliseconds
public suspend fun CodeDeployClient.waitUntilDeploymentSuccessful(request: GetDeploymentRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 15_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val deploymentInfo = it.deploymentInfo
val status = deploymentInfo?.status?.value
status == "Succeeded"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val deploymentInfo = it.deploymentInfo
val status = deploymentInfo?.status?.value
status == "Failed"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val deploymentInfo = it.deploymentInfo
val status = deploymentInfo?.status?.value
status == "Stopped"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getDeployment(request) }
}
public suspend fun CodeDeployClient.waitUntilDeploymentSuccessful(block: GetDeploymentRequest.Builder.() -> Unit): Outcome =
waitUntilDeploymentSuccessful(GetDeploymentRequest.Builder().apply(block).build())