Class: Ears::Middlewares::MaxRetries
- Inherits:
-
Ears::Middleware
- Object
- Ears::Middleware
- Ears::Middlewares::MaxRetries
- Defined in:
- lib/ears/middlewares/max_retries.rb
Overview
A middleware that automatically puts messages on an error queue when the specified number of retries are exceeded.
Instance Method Summary collapse
- #call(delivery_info, metadata, payload, app) ⇒ Object
-
#initialize(opts) ⇒ MaxRetries
constructor
A new instance of MaxRetries.
Constructor Details
#initialize(opts) ⇒ MaxRetries
Returns a new instance of MaxRetries.
10 11 12 13 14 |
# File 'lib/ears/middlewares/max_retries.rb', line 10 def initialize(opts) super() @retries = opts.fetch(:retries) @error_queue = opts.fetch(:error_queue) end |
Instance Method Details
#call(delivery_info, metadata, payload, app) ⇒ Object
16 17 18 19 20 |
# File 'lib/ears/middlewares/max_retries.rb', line 16 def call(delivery_info, , payload, app) return handle_exceeded(payload) if retries_exceeded?() app.call(delivery_info, , payload) end |