Class: Remon::EventProcessor
- Inherits:
-
Object
- Object
- Remon::EventProcessor
- Includes:
- Logger
- Defined in:
- lib/remon/event_processor.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(pr) ⇒ EventProcessor
constructor
A new instance of EventProcessor.
- #process_event ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Logger
Constructor Details
#initialize(pr) ⇒ EventProcessor
Returns a new instance of EventProcessor.
9 10 11 12 |
# File 'lib/remon/event_processor.rb', line 9 def initialize(pr) @proc = pr @queue = Queue.new end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/remon/event_processor.rb', line 7 def queue @queue end |
Instance Method Details
#process_event ⇒ Object
21 22 23 24 25 26 |
# File 'lib/remon/event_processor.rb', line 21 def process_event event = @queue.pop @proc.call event rescue => e logger.warn "warn error #{e.}" end |
#start ⇒ Object
14 15 16 17 18 19 |
# File 'lib/remon/event_processor.rb', line 14 def start @thread ||= Thread.new do logger.debug { "starting event processor" } loop { process_event } end end |
#stop ⇒ Object
28 29 30 |
# File 'lib/remon/event_processor.rb', line 28 def stop Thread.kill @thread if @thread end |