Class: Rreplay::ReplayRunner
- Inherits:
-
Object
- Object
- Rreplay::ReplayRunner
- Defined in:
- lib/rreplay/replay_runner.rb
Instance Method Summary collapse
-
#initialize(endpoint, target, format: :msgpack, debug: false) ⇒ ReplayRunner
constructor
A new instance of ReplayRunner.
- #run ⇒ Object
Constructor Details
#initialize(endpoint, target, format: :msgpack, debug: false) ⇒ ReplayRunner
Returns a new instance of ReplayRunner.
11 12 13 14 15 16 |
# File 'lib/rreplay/replay_runner.rb', line 11 def initialize(endpoint, target, format: :msgpack, debug: false) @http = Http.new(endpoint) @format = Rreplay::Format.of(format) @target = target @debugger = Debugger.new($stdout, debug) end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rreplay/replay_runner.rb', line 18 def run output = OutputBuilder.new(style: :json) file_names.each do |file_name| ::File.open(file_name) do |file| @debugger.out { { message: "Open file: #{file_name}" } } file.each_line do |line| next if line.start_with?('#') # LogDevice's header line.chomp! record = deserialize(line) result = @http.call(record['request']) @debugger.out { output.call(record, result) } end end end rescue Interrupt @debugger.out { "Interrupted." } end |