commonMain.aws.sdk.kotlin.services.transfer.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of transfer-jvm Show documentation
Show all versions of transfer-jvm Show documentation
The AWS SDK for Kotlin client for Transfer
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.transfer.waiters
import aws.sdk.kotlin.services.transfer.TransferClient
import aws.sdk.kotlin.services.transfer.model.DescribeServerRequest
import aws.sdk.kotlin.services.transfer.model.DescribeServerResponse
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 TransferClient.waitUntilServerOffline(request: DescribeServerRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 30_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 3_600_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val server = it.server
val state = server?.state?.value
state == "OFFLINE"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val server = it.server
val state = server?.state?.value
state == "STOP_FAILED"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeServer(request) }
}
public suspend fun TransferClient.waitUntilServerOffline(block: DescribeServerRequest.Builder.() -> Unit): Outcome =
waitUntilServerOffline(DescribeServerRequest.Builder().apply(block).build())
public suspend fun TransferClient.waitUntilServerOnline(request: DescribeServerRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 30_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 3_600_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val server = it.server
val state = server?.state?.value
state == "ONLINE"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val server = it.server
val state = server?.state?.value
state == "START_FAILED"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeServer(request) }
}
public suspend fun TransferClient.waitUntilServerOnline(block: DescribeServerRequest.Builder.() -> Unit): Outcome =
waitUntilServerOnline(DescribeServerRequest.Builder().apply(block).build())