Class: Shoryuken::Waiter::Enqueuer

Inherits:
Object
  • Object
show all
Extended by:
Util
Defined in:
lib/shoryuken/waiter/enqueuer.rb

Class Method Summary collapse

Class Method Details

.enqueue_items(table, items) ⇒ Object

TODO If there is ever support for tables that don’t map 1:1 to queues, a query may return items intended for many queues, so in order to be able to batch then with #send_messages, the would need to be sorted

TODO If the actor were to crash in the middle of a batch, messages could get lost



13
14
15
16
17
18
19
20
# File 'lib/shoryuken/waiter/enqueuer.rb', line 13

def enqueue_items(table, items)
  return if items.empty?

  queue_name = items.first["sqs_message_body"]["queue_name"]
  queue = Shoryuken::Client.queues(queue_name)

  send_messages(queue, items.map { |item| message(table, item) })
end