Class: Shoryuken::Middleware::Server::AutoDelete

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/middleware/server/auto_delete.rb

Instance Method Summary collapse

Instance Method Details

#call(worker, queue, sqs_msg, _body) ⇒ Object


5
6
7
8
9
10
11
12
13
# File 'lib/shoryuken/middleware/server/auto_delete.rb', line 5

def call(worker, queue, sqs_msg, _body)
  yield

  return unless worker.class.auto_delete?

  entries = [sqs_msg].flatten.map.with_index { |message, i| { id: i.to_s, receipt_handle: message.receipt_handle } }

  Shoryuken::Client.queues(queue).delete_messages(entries: entries)
end