Module: Shoryuken::Waiter

Defined in:
lib/shoryuken/waiter.rb,
lib/shoryuken/waiter/querier.rb,
lib/shoryuken/waiter/version.rb,
lib/shoryuken/waiter/enqueuer.rb

Defined Under Namespace

Classes: Enqueuer, Querier

Constant Summary collapse

MAX_QUEUE_DELAY =
15 * 60
DEFAULT_POLL_DELAY =
5 * 60
TABLE_PRIMARY_ITEM_KEY_VALUE =
"shoryuken-waiter"
VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.clientObject



15
16
17
# File 'lib/shoryuken/waiter.rb', line 15

def client
  @client ||= Aws::DynamoDB::Client.new
end

.optionsObject



34
35
36
# File 'lib/shoryuken/waiter.rb', line 34

def options
  @options ||= Shoryuken.options[:waiter] || {}
end

.poll_delayObject



38
39
40
# File 'lib/shoryuken/waiter.rb', line 38

def poll_delay
  options[:delay] || DEFAULT_POLL_DELAY
end

.tablesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shoryuken/waiter.rb', line 19

def tables
  @tables ||= Shoryuken.queues.uniq.map do |queue_name|
    table = Aws::DynamoDB::Table.new(queue_name, client: client)

    begin
      table.table_arn
      Shoryuken.logger.debug { "[Shoryuken::Waiter] Found wait table for queue '#{queue_name}'" }
      table
    rescue Aws::DynamoDB::Errors::ResourceNotFoundException
      Shoryuken.logger.debug { "[Shoryuken::Waiter] No wait table for queue '#{queue_name}'" }
      nil
    end
  end.compact
end