Skip to content

Commit

Permalink
Make result code processing code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
sharshenov committed Jun 15, 2020
1 parent c847760 commit c2843bf
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/sneakers/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,12 @@ def process_work(delivery_info, metadata, msg, handler)
message: msg, delivery_info: delivery_info, metadata: metadata)
ensure
if @should_ack
if res == :ack
# note to future-self. never acknowledge multiple (multiple=true) messages under threads.
handler.acknowledge(delivery_info, metadata, msg)
elsif res == :error
handler.error(delivery_info, metadata, msg, error)
elsif res == :reject
handler.reject(delivery_info, metadata, msg)
elsif res == :requeue
handler.reject(delivery_info, metadata, msg, true)
case res
# note to future-self. never acknowledge multiple (multiple=true) messages under threads.
when :ack then handler.acknowledge(delivery_info, metadata, msg)
when :error then handler.error(delivery_info, metadata, msg, error)
when :reject then handler.reject(delivery_info, metadata, msg)
when :requeue then handler.reject(delivery_info, metadata, msg, true)
else
handler.noop(delivery_info, metadata, msg)
end
Expand Down

0 comments on commit c2843bf

Please sign in to comment.