Class: LaGear::Sneakers::Handlers::ExponentialBackoff
- Inherits:
-
Object
- Object
- LaGear::Sneakers::Handlers::ExponentialBackoff
- Defined in:
- lib/la_gear/sneakers/exponential_backoff.rb
Instance Method Summary collapse
- #acknowledge(delivery_info, _metadata, _msg) ⇒ Object
- #error(hdr, props, msg, err) ⇒ Object
-
#initialize(channel, _queue, opts) ⇒ ExponentialBackoff
constructor
A new instance of ExponentialBackoff.
- #noop(_delivery_info, _metadata, _msg) ⇒ Object
- #reject(hdr, props, msg, _requeue = false) ⇒ Object
- #timeout(hdr, props, msg) ⇒ Object
Constructor Details
#initialize(channel, _queue, opts) ⇒ ExponentialBackoff
Returns a new instance of ExponentialBackoff.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/la_gear/sneakers/exponential_backoff.rb', line 5 def initialize(channel, _queue, opts) @channel = channel @opts = opts exchange = @opts.fetch(:exchange) @handler_opts = @opts.fetch(:handler_opts, {}) retry_name = @handler_opts.fetch(:retryexchange, "#{exchange}.retry") error_name = @handler_opts.fetch(:errorexchange, "#{exchange}.error") @publish_channel = setup_publish_channel @retry_exchange = setup_retry(@publish_channel, retry_name, exchange) @error_exchange = setup_error(@publish_channel, error_name) @max_retries = @handler_opts.fetch(:max_retries, 5) @expiration = @handler_opts.fetch(:expiration, 1000) end |
Instance Method Details
#acknowledge(delivery_info, _metadata, _msg) ⇒ Object
23 24 25 |
# File 'lib/la_gear/sneakers/exponential_backoff.rb', line 23 def acknowledge(delivery_info, , _msg) @channel.acknowledge(delivery_info.delivery_tag, false) end |
#error(hdr, props, msg, err) ⇒ Object
31 32 33 |
# File 'lib/la_gear/sneakers/exponential_backoff.rb', line 31 def error(hdr, props, msg, err) retry_or_error(hdr, props, msg, err.to_s) end |
#noop(_delivery_info, _metadata, _msg) ⇒ Object
39 |
# File 'lib/la_gear/sneakers/exponential_backoff.rb', line 39 def noop(_delivery_info, , _msg); end |
#reject(hdr, props, msg, _requeue = false) ⇒ Object
27 28 29 |
# File 'lib/la_gear/sneakers/exponential_backoff.rb', line 27 def reject(hdr, props, msg, _requeue = false) retry_or_error(hdr, props, msg, 'rejected') end |
#timeout(hdr, props, msg) ⇒ Object
35 36 37 |
# File 'lib/la_gear/sneakers/exponential_backoff.rb', line 35 def timeout(hdr, props, msg) error(hdr, props, msg, 'Timeout: Sneakers worker timedout.') end |