Class: Aws::Waiters::Poller Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/waiters/poller.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Polls a single API operation inspecting the response data and/or error for states matching one of its acceptors.

Constant Summary collapse

RAISE_HANDLER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Seahorse::Client::Plugins::RaiseResponseErrors::Handler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Poller

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Poller.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :operation_name (required, String)
  • :acceptors (required, Array<Hash>)


17
18
19
20
# File 'lib/aws-sdk-core/waiters/poller.rb', line 17

def initialize(options = {})
  @operation_name = options.fetch(:operation_name)
  @acceptors = options.fetch(:acceptors)
end

Instance Attribute Details

#operation_nameSymbol (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Symbol)


23
24
25
# File 'lib/aws-sdk-core/waiters/poller.rb', line 23

def operation_name
  @operation_name
end

Instance Method Details

#call(options = {}) ⇒ Array<Symbol,Response>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Makes an API call, returning the resultant state and the response.

  • ‘:success` - A success state has been matched.

  • ‘:failure` - A terminate failure state has been matched.

  • ‘:retry` - The waiter may be retried.

  • ‘:error` - The waiter encountered an un-expected error.

Examples:

A trivial (bad) example of a waiter that polls indefinetly.


loop do

  state, resp = poller.call(client:client, params:{})

  case state
  when :success then return true
  when :failure then return false
  when :retry   then next
  when :error   then raise 'oops'
  end

end

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :client (required, Client)
  • :params (required, Hash)

Returns:

  • (Array<Symbol,Response>)


50
51
52
53
54
55
56
57
58
# File 'lib/aws-sdk-core/waiters/poller.rb', line 50

def call(options = {})
  response = send_request(options)
  @acceptors.each do |acceptor|
    if acceptor_matches?(acceptor, response)
      return [acceptor['state'].to_sym, response]
    end
  end
  [response.error ? :error : :retry, response]
end