Class: MessageProbe

Inherits:
Object
  • Object
show all
Includes:
MessageCommand
Defined in:
lib/pipeline_toolkit/message_probe.rb

Instance Attribute Summary

Attributes included from MessageCommand

#sys_pipe

Instance Method Summary collapse

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 process_message(msg)
  @count += 1
  if @count > @interval
    delta = Time.now - @prev_time
    log.info("#{@count / delta} msgs per second")
    reset
  end
  msg
end

#resetObject



19
20
21
22
# File 'lib/pipeline_toolkit/message_probe.rb', line 19

def reset
  @count = 0
  @prev_time = Time.now
end