Class: Norikra::Listener::MockAsync

Inherits:
Base
  • Object
show all
Defined in:
lib/norikra/listener/mock.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argument, query_name, query_group) ⇒ MockAsync

Returns a new instance of MockAsync.



30
31
32
33
34
# File 'lib/norikra/listener/mock.rb', line 30

def initialize(argument, query_name, query_group)
  super
  @stdout = STDOUT
  @repeat = @argument.to_i
end

Instance Attribute Details

#stdoutObject

Returns the value of attribute stdout.



28
29
30
# File 'lib/norikra/listener/mock.rb', line 28

def stdout
  @stdout
end

Class Method Details

.labelObject



24
25
26
# File 'lib/norikra/listener/mock.rb', line 24

def self.label
  "MOCK_ASYNC"
end

Instance Method Details

#process_async(events) ⇒ Object

[ [unixtime, event ], …



36
37
38
39
40
41
42
43
# File 'lib/norikra/listener/mock.rb', line 36

def process_async(events) # [ [unixtime, {event} ], ...
  # write events to STDOUT specified times, in background
  events.each do |time, e|
    @repeat.times do |i|
      @stdout.puts "#{@query_name}\t#{i + 1}\t#{Time.at(time)}\t" + JSON.dump(e)
    end
  end
end