
commonMain.aws.sdk.kotlin.services.elasticloadbalancingv2.waiters.Waiters.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.elasticloadbalancingv2.waiters
import aws.sdk.kotlin.services.elasticloadbalancingv2.ElasticLoadBalancingV2Client
import aws.sdk.kotlin.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest
import aws.sdk.kotlin.services.elasticloadbalancingv2.model.DescribeLoadBalancersResponse
import aws.sdk.kotlin.services.elasticloadbalancingv2.model.DescribeTargetHealthRequest
import aws.sdk.kotlin.services.elasticloadbalancingv2.model.DescribeTargetHealthResponse
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 aws.smithy.kotlin.runtime.retries.policy.RetryErrorType
import aws.smithy.kotlin.runtime.retries.policy.SuccessAcceptor
import aws.smithy.kotlin.runtime.util.flattenIfPossible
import kotlin.time.Duration.Companion.milliseconds
public suspend fun ElasticLoadBalancingV2Client.waitUntilLoadBalancerAvailable(request: DescribeLoadBalancersRequest = DescribeLoadBalancersRequest { }): 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 loadBalancers = it.loadBalancers
val loadBalancersOrEmpty = loadBalancers?.flattenIfPossible()
val projection = loadBalancersOrEmpty?.flatMap {
val state = it?.state
val code = state?.code?.value
listOfNotNull(code)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "active" }
},
OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
val loadBalancers = it.loadBalancers
val loadBalancersOrEmpty = loadBalancers?.flattenIfPossible()
val projection = loadBalancersOrEmpty?.flatMap {
val state = it?.state
val code = state?.code?.value
listOfNotNull(code)
}
(projection as List?)?.any { it == "provisioning" } ?: false
},
ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "LoadBalancerNotFound"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeLoadBalancers(request) }
}
public suspend fun ElasticLoadBalancingV2Client.waitUntilLoadBalancerAvailable(block: DescribeLoadBalancersRequest.Builder.() -> Unit): Outcome =
waitUntilLoadBalancerAvailable(DescribeLoadBalancersRequest.Builder().apply(block).build())
public suspend fun ElasticLoadBalancingV2Client.waitUntilLoadBalancerExists(request: DescribeLoadBalancersRequest = DescribeLoadBalancersRequest { }): 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>(
SuccessAcceptor(RetryDirective.TerminateAndSucceed, true),
ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "LoadBalancerNotFound"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeLoadBalancers(request) }
}
public suspend fun ElasticLoadBalancingV2Client.waitUntilLoadBalancerExists(block: DescribeLoadBalancersRequest.Builder.() -> Unit): Outcome =
waitUntilLoadBalancerExists(DescribeLoadBalancersRequest.Builder().apply(block).build())
public suspend fun ElasticLoadBalancingV2Client.waitUntilLoadBalancersDeleted(request: DescribeLoadBalancersRequest = DescribeLoadBalancersRequest { }): 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.RetryError(RetryErrorType.ServerSide)) {
val loadBalancers = it.loadBalancers
val loadBalancersOrEmpty = loadBalancers?.flattenIfPossible()
val projection = loadBalancersOrEmpty?.flatMap {
val state = it?.state
val code = state?.code?.value
listOfNotNull(code)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "active" }
},
ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "LoadBalancerNotFound"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeLoadBalancers(request) }
}
public suspend fun ElasticLoadBalancingV2Client.waitUntilLoadBalancersDeleted(block: DescribeLoadBalancersRequest.Builder.() -> Unit): Outcome =
waitUntilLoadBalancersDeleted(DescribeLoadBalancersRequest.Builder().apply(block).build())
public suspend fun ElasticLoadBalancingV2Client.waitUntilTargetDeregistered(request: DescribeTargetHealthRequest): 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>(
ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "InvalidTarget"),
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val targetHealthDescriptions = it.targetHealthDescriptions
val targetHealthDescriptionsOrEmpty = targetHealthDescriptions?.flattenIfPossible()
val projection = targetHealthDescriptionsOrEmpty?.flatMap {
val targetHealth = it?.targetHealth
val state = targetHealth?.state?.value
listOfNotNull(state)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "unused" }
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeTargetHealth(request) }
}
public suspend fun ElasticLoadBalancingV2Client.waitUntilTargetDeregistered(block: DescribeTargetHealthRequest.Builder.() -> Unit): Outcome =
waitUntilTargetDeregistered(DescribeTargetHealthRequest.Builder().apply(block).build())
public suspend fun ElasticLoadBalancingV2Client.waitUntilTargetInService(request: DescribeTargetHealthRequest): 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 targetHealthDescriptions = it.targetHealthDescriptions
val targetHealthDescriptionsOrEmpty = targetHealthDescriptions?.flattenIfPossible()
val projection = targetHealthDescriptionsOrEmpty?.flatMap {
val targetHealth = it?.targetHealth
val state = targetHealth?.state?.value
listOfNotNull(state)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "healthy" }
},
ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InvalidInstance"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeTargetHealth(request) }
}
public suspend fun ElasticLoadBalancingV2Client.waitUntilTargetInService(block: DescribeTargetHealthRequest.Builder.() -> Unit): Outcome =
waitUntilTargetInService(DescribeTargetHealthRequest.Builder().apply(block).build())
© 2015 - 2025 Weber Informatics LLC | Privacy Policy