commonMain.aws.sdk.kotlin.services.dsql.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dsql-jvm Show documentation
Show all versions of dsql-jvm Show documentation
The AWS SDK for Kotlin client for DSQL
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.dsql.waiters
import aws.sdk.kotlin.services.dsql.DsqlClient
import aws.sdk.kotlin.services.dsql.model.GetClusterRequest
import aws.sdk.kotlin.services.dsql.model.GetClusterResponse
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.ErrorTypeAcceptor
import aws.smithy.kotlin.runtime.retries.policy.OutputAcceptor
import aws.smithy.kotlin.runtime.retries.policy.RetryDirective
import kotlin.time.Duration.Companion.milliseconds
/**
* Wait until a Cluster is ACTIVE
*/
public suspend fun DsqlClient.waitUntilClusterActive(request: GetClusterRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 2_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it.status?.value
status == "ACTIVE"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getCluster(request) }
}
/**
* Wait until a Cluster is ACTIVE
*/
public suspend fun DsqlClient.waitUntilClusterActive(block: GetClusterRequest.Builder.() -> Unit): Outcome =
waitUntilClusterActive(GetClusterRequest.Builder().apply(block).build())
/**
* Wait until a Cluster is gone
*/
public suspend fun DsqlClient.waitUntilClusterNotExists(request: GetClusterRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 2_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundException"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getCluster(request) }
}
/**
* Wait until a Cluster is gone
*/
public suspend fun DsqlClient.waitUntilClusterNotExists(block: GetClusterRequest.Builder.() -> Unit): Outcome =
waitUntilClusterNotExists(GetClusterRequest.Builder().apply(block).build())
© 2015 - 2024 Weber Informatics LLC | Privacy Policy