Class: Proletariat::ExceptionHandler
- Inherits:
-
Actor
- Object
- Concurrent::Actor::RestartingContext
- Actor
- Proletariat::ExceptionHandler
- Includes:
- Concerns::Logging
- Defined in:
- lib/proletariat/exception_handler.rb
Overview
Public: Handles messages whose work raised an exception. Should overwrite
the #work method to implement retry/drop logic.
Direct Known Subclasses
Instance Method Summary collapse
-
#actor_work(message) ⇒ Object
Internal: Handles the Actor mailbox.
-
#initialize(queue_name) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
-
#setup ⇒ Object
Public: Callback hook for initialization.
-
#work(body, to, headers) ⇒ Object
Public: Handles an incoming message to perform background work.
-
#work_method ⇒ Object
Public: Use #actor_work to handle the actor mailbox.
Methods included from Concerns::Logging
Methods inherited from Actor
Methods included from ActorCommon
Constructor Details
#initialize(queue_name) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
9 10 11 12 |
# File 'lib/proletariat/exception_handler.rb', line 9 def initialize(queue_name) @queue_name = queue_name setup end |
Instance Method Details
#actor_work(message) ⇒ Object
Internal: Handles the Actor mailbox. Delegates work to #work.
message - A Message to send.
17 18 19 |
# File 'lib/proletariat/exception_handler.rb', line 17 def actor_work() work .body, .to, .headers if .is_a?(Message) end |
#setup ⇒ Object
Public: Callback hook for initialization.
22 23 |
# File 'lib/proletariat/exception_handler.rb', line 22 def setup end |
#work(body, to, headers) ⇒ Object
Public: Handles an incoming message to perform background work.
body - The failed message body. to - The failed message’s routing key. headers - The failed message’s headers.
Raises NotImplementedError unless implemented in subclass.
32 33 34 |
# File 'lib/proletariat/exception_handler.rb', line 32 def work(body, to, headers) fail NotImplementedError end |
#work_method ⇒ Object
Public: Use #actor_work to handle the actor mailbox.
37 38 39 |
# File 'lib/proletariat/exception_handler.rb', line 37 def work_method :actor_work end |