Module: Aws::NimbleStudio::Waiters
- Defined in:
- gems/aws-sdk-nimblestudio/lib/aws-sdk-nimblestudio/waiters.rb
Overview
Waiters are utility methods that poll for a particular state to occur on a client. Waiters can fail after a number of attempts at a polling interval defined for the service client.
For a list of operations that can be waited for and the client methods called for each operation, see the table below or the Client#wait_until field documentation for the Client.
Invoking a Waiter
To invoke a waiter, call #wait_until on a Client. The first parameter is the waiter name, which is specific to the service client and indicates which operation is being waited for. The second parameter is a hash of parameters that are passed to the client method called by the waiter, which varies according to the waiter name.
Wait Failures
To catch errors in a waiter, use WaiterFailed, as shown in the following example.
rescue rescue Aws::Waiters::Errors::WaiterFailed => error
puts "failed waiting for instance running: #{error.message}
end
Configuring a Waiter
Each waiter has a default polling interval and a maximum number of
attempts it will make before returning control to your program.
To set these values, use the max_attempts
and delay
parameters
in your #wait_until
call.
The following example waits for up to 25 seconds, polling every five seconds.
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
To disable wait failures, set the value of either of these parameters
to nil
.
Extending a Waiter
To modify the behavior of waiters, you can register callbacks that are triggered before each polling attempt and before waiting.
The following example implements an exponential backoff in a waiter by doubling the amount of time to wait on every attempt.
client.wait_until(...) do |w|
w.interval = 0 # disable normal sleep
w.before_wait do |n, resp|
sleep(n ** 2)
end
end
Available Waiters
The following table lists the valid waiter names, the operations they call,
and the default :delay
and :max_attempts
values.
waiter_name | params | :delay | :max_attempts |
---|---|---|---|
launch_profile_deleted | Client#get_launch_profile | 5 | 150 |
launch_profile_ready | Client#get_launch_profile | 5 | 150 |
streaming_image_deleted | Client#get_streaming_image | 2 | 60 |
streaming_image_ready | Client#get_streaming_image | 2 | 60 |
streaming_session_deleted | Client#get_streaming_session | 5 | 180 |
streaming_session_ready | Client#get_streaming_session | 10 | 180 |
streaming_session_stopped | Client#get_streaming_session | 5 | 180 |
streaming_session_stream_ready | Client#get_streaming_session_stream | 5 | 30 |
studio_component_deleted | Client#get_studio_component | 1 | 120 |
studio_component_ready | Client#get_studio_component | 2 | 60 |
studio_deleted | Client#get_studio | 2 | 60 |
studio_ready | Client#get_studio | 2 | 60 |
Defined Under Namespace
Classes: LaunchProfileDeleted, LaunchProfileReady, StreamingImageDeleted, StreamingImageReady, StreamingSessionDeleted, StreamingSessionReady, StreamingSessionStopped, StreamingSessionStreamReady, StudioComponentDeleted, StudioComponentReady, StudioDeleted, StudioReady