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.



13
14
15
16
# File 'lib/aws-sdk-core/waiters/poller.rb', line 13

def initialize(options = {})
  @operation_name = underscore(options['operation']).to_sym
  @acceptors = options['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)


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

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 trival (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>)


46
47
48
49
50
51
52
53
54
# File 'lib/aws-sdk-core/waiters/poller.rb', line 46

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