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

Constant Summary collapse

@@ignored_units =
Concurrent::Set.new

Instance Method Summary collapse

Constructor Details

#initialize(datastore:, event_queue:, whitelist: nil) ⇒ EventProcessor

Returns a new instance of EventProcessor.



13
14
15
16
17
# File 'lib/tac_scribe/event_processor.rb', line 13

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

Instance Method Details

#process_event(wrapped_event) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/tac_scribe/event_processor.rb', line 30

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



19
20
21
22
23
24
25
26
27
28
# File 'lib/tac_scribe/event_processor.rb', line 19

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