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
14
15
16
17
# File 'lib/shoryuken/middleware/server/auto_delete.rb', line 5

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

  auto_delete = worker.class.get_shoryuken_options['delete'] || worker.class.get_shoryuken_options['auto_delete']

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

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