Class: DispatchRider::Demultiplexer
- Inherits:
-
Object
- Object
- DispatchRider::Demultiplexer
- Defined in:
- lib/dispatch-rider/demultiplexer.rb
Instance Attribute Summary collapse
-
#dispatcher ⇒ Object
readonly
Returns the value of attribute dispatcher.
-
#error_handler ⇒ Object
readonly
Returns the value of attribute error_handler.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(queue, dispatcher, error_handler) ⇒ Demultiplexer
constructor
A new instance of Demultiplexer.
- #start ⇒ Object
- #stop(reason: nil) ⇒ Object
Constructor Details
#initialize(queue, dispatcher, error_handler) ⇒ Demultiplexer
Returns a new instance of Demultiplexer.
10 11 12 13 14 15 16 |
# File 'lib/dispatch-rider/demultiplexer.rb', line 10 def initialize(queue, dispatcher, error_handler) @queue = queue @dispatcher = dispatcher @error_handler = error_handler @continue = true @current_message = nil end |
Instance Attribute Details
#dispatcher ⇒ Object (readonly)
Returns the value of attribute dispatcher.
8 9 10 |
# File 'lib/dispatch-rider/demultiplexer.rb', line 8 def dispatcher @dispatcher end |
#error_handler ⇒ Object (readonly)
Returns the value of attribute error_handler.
8 9 10 |
# File 'lib/dispatch-rider/demultiplexer.rb', line 8 def error_handler @error_handler end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
8 9 10 |
# File 'lib/dispatch-rider/demultiplexer.rb', line 8 def queue @queue end |
Instance Method Details
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dispatch-rider/demultiplexer.rb', line 18 def start do_loop do begin handle_next_queue_item rescue => exception error_handler.call(Message.new(subject: "TopLevelError", body: {}), exception) throw :done end end self end |
#stop(reason: nil) ⇒ Object
30 31 32 33 |
# File 'lib/dispatch-rider/demultiplexer.rb', line 30 def stop(reason: nil) @continue = false Logging::LifecycleLogger.log_got_stop reason, @current_message if @current_message end |