soto-project / soto

Swift SDK for AWS that works on Linux, macOS and iOS
https://soto.codes
Apache License 2.0
880 stars 83 forks source link

Add support for waiter using JMESPath #504

Closed adam-fowler closed 3 years ago

adam-fowler commented 3 years ago

Waiters are a client-side abstraction used to poll a resource until a desired state is reached, or until it is determined that the resource will never enter into the desired state. This is a common task when working with services that are eventually consistent like Amazon S3 or services that asynchronously create resources like Amazon EC2. Writing logic to continuously poll the status of a resource can be cumbersome and error-prone. The goal of waiters is to move this responsibility out of customer code and onto Soto.

See https://github.com/soto-project/soto-core/pull/446 This implementation uses JMESPath for path matching.

A simple example of usage would be creating a DynamoDB table and waiting until it is ready to be used

let input = DynamoDB.CreateTableInput(
    ...
    tableName: name
)
return dynamoDB.createTable(input).flatMap { _ in
    dynamoDB.waitUntilTableExists(.init(tableName: name))
}