Class: TacScribe::EventProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/tac_scribe/event_processor.rb

Overview

Processes the events emitted by the Ruby Tacview Client

Instance Method Summary collapse

Constructor Details

#initialize(datastore:, event_queue:) ⇒ EventProcessor

Returns a new instance of EventProcessor.



10
11
12
13
# File 'lib/tac_scribe/event_processor.rb', line 10

def initialize(datastore:, event_queue:)
  @datastore = datastore
  @event_queue = event_queue
end

Instance Method Details

#process_event(wrapped_event) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/tac_scribe/event_processor.rb', line 26

def process_event(wrapped_event)
  case wrapped_event[:type]
  when :update_object
    update_object(wrapped_event[:event], wrapped_event[:time])
  when :delete_object
    delete_object(wrapped_event[:object_id])
  end
end

#startObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/tac_scribe/event_processor.rb', line 15

def start
  loop do
    wrapped_event = @event_queue.events.shift
    process_event(wrapped_event)
  rescue StandardError => e
    puts wrapped_event
    puts e.inspect
    next
  end
end