Class: Stax::Aws::Sdk

Inherits:
Object
  • Object
show all
Defined in:
lib/stax/aws/sdk.rb

Constant Summary collapse

RETRY_LIMIT =
ENV['STAX_RETRY_LIMIT'] || 100

Class Method Summary collapse

Class Method Details

.paginate(thing) ⇒ Object

universal paginator for aws-sdk calls



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stax/aws/sdk.rb', line 8

def self.paginate(thing)
  token = nil
  things = []
  loop do
    resp = yield(token)
    things += resp.send(thing)
    ## some apis use marker, some use token
    token = resp.respond_to?(:next_marker) ? resp.next_marker : resp.next_token
    break if token.nil?
  end
  things
end