Review the inherited state of V1 waiters and determine which changes are necessary for V2.
(Feel free to comment on this issue with desired changes).
This is what I'm doing in Scala using the async clients. I imagine you could do something similar in java.
def whileInProgress[Request <: AmazonWebServiceRequest, Response](
method: Request => java.util.concurrent.CompletableFuture[Response],
request: Request,
isInProgress: Response ⇒ Boolean,
duration: Duration = 30 seconds): Future[Response] = {
def loop(): Future[Response] = {
val fut = method(request).toScala
fut.flatMap { response =>
if (isInProgress(response)) {
Thread.sleep(duration.toMillis)
loop
}
fut
}
}
loop
}
Feature Request from v1: https://github.com/aws/aws-sdk-java/issues/815
Is this ever going to be implemented?
Yes. Unfortunately, we cannot provide a date.
Hey all, we have released waiters in 2.15.0.
Below is the sample code of how to use it:
DynamoDbClient dynamo = DynamoDbClient.create();
DynamoDbWaiter waiter = dynamo.waiter();
WaiterResponse<DescribeTableResponse> waiterResponse =
waiter.waitUntilTableExists(r -> r.tableName("myTable"));
// print out the matched response with a tableStatus of ACTIVE
waiterResponse.matched().response().ifPresent(System.out::println);
DynamoDbAsyncClient asyncDynamo = DynamoDbAsyncClient.create();
DynamoDbAsyncWaiter asyncWaiter = asyncDynamo.waiter();
CompletableFuture<WaiterResponse<DescribeTableResponse>> waiterResponse =
asyncWaiter.waitUntilTableNotExists(r -> r.tableName("myTable"));
waiterResponse.whenComplete((r, t) -> {
if (t == null) {
// print out the matched ResourceNotFoundException
r.matched().exception().ifPresent(System.out::println);
}
}).join();
To learn more, check out our blog post and developer guide:
https://aws.amazon.com/blogs/developer/using-waiters-in-the-aws-sdk-for-java-2-x/
https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/waiters.html
Let us know if you have any feedback! 😃
all works well, many thanks
Most helpful comment
This is what I'm doing in Scala using the async clients. I imagine you could do something similar in java.