Class: ExponentialRetry
- Inherits:
-
Object
- Object
- ExponentialRetry
- Defined in:
- lib/sneakers_exponential_retry.rb
Constant Summary collapse
- MINUTE =
60 * 1000
- DEFAULT_MAX_RETRY_COUNT =
14
Instance Method Summary collapse
- #acknowledge(hdr, props, msg) ⇒ Object
- #error(hdr, props, msg, err) ⇒ Object
-
#initialize(channel, queue, opts) ⇒ ExponentialRetry
constructor
A new instance of ExponentialRetry.
- #noop(hdr, props, msg) ⇒ Object
- #reject(hdr, props, msg, requeue = false) ⇒ Object
- #timeout(hdr, props, msg) ⇒ Object
Constructor Details
#initialize(channel, queue, opts) ⇒ ExponentialRetry
Returns a new instance of ExponentialRetry.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sneakers_exponential_retry.rb', line 7 def initialize(channel, queue, opts) @channel = channel @max_retry_count = calculate_max_retry_count(opts) @retry_exchange = create_retry_exchange(queue.name) @logger = opts[:handler_options] ? opts[:handler_options][:logger] : nil create_retry_queue(queue.name, opts[:exchange]) .bind(@retry_exchange, :routing_key => '#') end |
Instance Method Details
#acknowledge(hdr, props, msg) ⇒ Object
41 42 43 |
# File 'lib/sneakers_exponential_retry.rb', line 41 def acknowledge(hdr, props, msg) @channel.acknowledge(hdr.delivery_tag, false) end |
#error(hdr, props, msg, err) ⇒ Object
49 50 51 |
# File 'lib/sneakers_exponential_retry.rb', line 49 def error(hdr, props, msg, err) (hdr, props, msg, err) end |
#noop(hdr, props, msg) ⇒ Object
95 96 |
# File 'lib/sneakers_exponential_retry.rb', line 95 def noop(hdr, props, msg) end |
#reject(hdr, props, msg, requeue = false) ⇒ Object
45 46 47 |
# File 'lib/sneakers_exponential_retry.rb', line 45 def reject(hdr, props, msg, requeue=false) @channel.reject(hdr.delivery_tag, requeue) end |
#timeout(hdr, props, msg) ⇒ Object
91 92 93 |
# File 'lib/sneakers_exponential_retry.rb', line 91 def timeout(hdr, props, msg) reject(hdr, props, msg) end |