Class: SneakersHandlers::RetryHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/sneakers_handlers/retry_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(channel, queue, options) ⇒ RetryHandler

Returns a new instance of RetryHandler.



27
28
29
30
31
32
33
34
# File 'lib/sneakers_handlers/retry_handler.rb', line 27

def initialize(channel, queue, options)
  @channel = channel
  @queue = queue
  @routing_key = options[:routing_key]
  @max_retry = options[:max_retry] || 5

  create_dlx(channel, queue, options)
end

Instance Method Details

#acknowledge(hdr, _props, _msg) ⇒ Object



36
37
38
# File 'lib/sneakers_handlers/retry_handler.rb', line 36

def acknowledge(hdr, _props, _msg)
  @channel.acknowledge(hdr.delivery_tag, false)
end

#error(hdr, props, msg, err) ⇒ Object



44
45
46
# File 'lib/sneakers_handlers/retry_handler.rb', line 44

def error(hdr, props, msg, err)
  retry_message(hdr, props, msg, err.inspect)
end

#noop(_hdr, _props, _msg) ⇒ Object



52
53
# File 'lib/sneakers_handlers/retry_handler.rb', line 52

def noop(_hdr, _props, _msg)
end

#reject(hdr, props, msg, requeue = false) ⇒ Object



40
41
42
# File 'lib/sneakers_handlers/retry_handler.rb', line 40

def reject(hdr, props, msg, requeue = false)
  retry_message(hdr, props, msg, :reject)
end

#timeout(hdr, props, msg) ⇒ Object



48
49
50
# File 'lib/sneakers_handlers/retry_handler.rb', line 48

def timeout(hdr, props, msg)
  retry_message(hdr, props, msg, :timeout)
end