A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdkforruby/api/Aws/Waiters/Waiter.html below:

Waiter — AWS SDK for Ruby V2

You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::Waiters::Waiter
Inherits:
Object show all
Defined in:
aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb
Instance Attribute Summary collapse Instance Method Summary collapse Instance Attribute Details #delay ⇒ Float Also known as: interval
24
25
26
# File 'aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb', line 24

def delay
  @delay
end
#max_attempts ⇒ Integer
21
22
23
# File 'aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb', line 21

def max_attempts
  @max_attempts
end
Instance Method Details #before_attempt {|attempts| ... } ⇒ Object

Register a callback that is invoked before every polling attempt. Yields the number of attempts made so far.

waiter.before_attempt do |attempts|
  puts "#{attempts} made, about to make attempt #{attempts + 1}"
end

Throwing :success or :failure from the given block will stop the waiter and return or raise. You can pass a custom message to the throw:

waiter.before_attempt do |attempts|
  throw :failure, 'custom-error-message'
end

waiter.before_attempt do |attempts|
  throw :success
end
51
52
53
# File 'aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb', line 51

def before_attempt(&block)
  @before_attempt << block if block_given?
end
#before_wait {|attempts, response| ... } ⇒ Object

Register a callback that is invoked after an attempt but before sleeping. Yields the number of attempts made and the previous response.

waiter.before_wait do |attempts, response|
  puts "#{attempts} made"
  puts response.error.inspect
  puts response.data.inspect
end

Throwing :success or :failure from the given block will stop the waiter and return or raise. You can pass a custom message to the throw:

waiter.before_attempt do |attempts|
  throw :failure, 'custom-error-message'
end

waiter.before_attempt do |attempts|
  throw :success
end
82
83
84
# File 'aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb', line 82

def before_wait(&block)
  @before_wait << block if block_given?
end
#wait(options) ⇒ Object
88
89
90
91
92
93
94
95
# File 'aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb', line 88

def wait(options)
  catch(:success) do
    failure_msg = catch(:failure) do
      return poll(options)
    end
    raise Errors::WaiterFailed.new(failure_msg || 'waiter failed')
  end || true
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4