Class: MessageProbe
- Inherits:
-
Object
- Object
- MessageProbe
- Includes:
- MessageCommand
- Defined in:
- lib/pipeline_toolkit/message_probe.rb
Instance Attribute Summary
Attributes included from MessageCommand
Instance Method Summary collapse
-
#initialize(opts) ⇒ MessageProbe
constructor
A new instance of MessageProbe.
- #process_message(msg) ⇒ Object
- #reset ⇒ Object
Methods included from MessageCommand
#ack_msg, #init_loop, #pass_on_msg, #process_line, #process_system, #shutdown, #start
Constructor Details
#initialize(opts) ⇒ MessageProbe
Returns a new instance of MessageProbe.
4 5 6 7 |
# File 'lib/pipeline_toolkit/message_probe.rb', line 4 def initialize(opts) @interval = opts.interval reset end |
Instance Method Details
#process_message(msg) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/pipeline_toolkit/message_probe.rb', line 9 def (msg) @count += 1 if @count > @interval delta = Time.now - @prev_time log.info("#{@count / delta} msgs per second") reset end msg end |
#reset ⇒ Object
19 20 21 22 |
# File 'lib/pipeline_toolkit/message_probe.rb', line 19 def reset @count = 0 @prev_time = Time.now end |