commonMain.aws.sdk.kotlin.services.kinesis.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kinesis-jvm Show documentation
Show all versions of kinesis-jvm Show documentation
The AWS SDK for Kotlin client for Kinesis
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.kinesis.waiters
import aws.sdk.kotlin.services.kinesis.KinesisClient
import aws.sdk.kotlin.services.kinesis.model.DescribeStreamRequest
import aws.sdk.kotlin.services.kinesis.model.DescribeStreamResponse
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
public suspend fun KinesisClient.waitUntilStreamExists(request: DescribeStreamRequest = DescribeStreamRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val streamDescription = it.streamDescription
val streamStatus = streamDescription?.streamStatus?.value
streamStatus == "ACTIVE"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeStream(request) }
}
public suspend fun KinesisClient.waitUntilStreamExists(block: DescribeStreamRequest.Builder.() -> Unit): Outcome =
waitUntilStreamExists(DescribeStreamRequest.Builder().apply(block).build())
public suspend fun KinesisClient.waitUntilStreamNotExists(request: DescribeStreamRequest = DescribeStreamRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_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) { describeStream(request) }
}
public suspend fun KinesisClient.waitUntilStreamNotExists(block: DescribeStreamRequest.Builder.() -> Unit): Outcome =
waitUntilStreamNotExists(DescribeStreamRequest.Builder().apply(block).build())