Class: Lepus::Consumers::Middlewares::MaxRetry
- Inherits:
-
Middleware
- Object
- Middleware
- Lepus::Consumers::Middlewares::MaxRetry
- Includes:
- AppExecutor
- Defined in:
- lib/lepus/consumers/middlewares/max_retry.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(message, app) ⇒ Object
-
#initialize(retries:, error_queue: nil) ⇒ MaxRetry
constructor
A new instance of MaxRetry.
Methods included from AppExecutor
#handle_thread_error, #wrap_in_app_executor
Constructor Details
#initialize(retries:, error_queue: nil) ⇒ MaxRetry
Returns a new instance of MaxRetry.
14 15 16 17 18 19 |
# File 'lib/lepus/consumers/middlewares/max_retry.rb', line 14 def initialize(retries:, error_queue: nil) super @retries = retries @error_queue = error_queue end |
Instance Method Details
#call(message, app) ⇒ Object
21 22 23 24 25 |
# File 'lib/lepus/consumers/middlewares/max_retry.rb', line 21 def call(, app) return handle_exceeded() if retries_exceeded?(.) app.call() end |