Class: EventDestination

Inherits:
Object
  • Object
show all
Includes:
Celluloid, ETLConsumer, ETLProducer
Defined in:
lib/actors/event_destination.rb

Overview

A consumer that receives and saves arrays of Events and then sends them to the next actor.

Instance Method Summary collapse

Methods included from ETLProducer

#buffer_empty?, #buffer_full?, #buffer_pop, #buffer_put, #emit_eof, #emit_row, #output=, #output_hungry?, #output_row, #process_eof, #produce_row, #receive_hungry

Methods included from ETLBase

#empty?, #eof_received?, #logger, #mark_empty!, #receive_eof, #unmark_empty!

Methods included from ETLConsumer

#consume_row, #input=, #notify_hungry, #pop_processed_row, #processed_row, #processed_row=, #start!

Constructor Details

#initialize(input, output, sync = nil) ⇒ EventDestination

Returns a new instance of EventDestination.


13
14
15
16
17
# File 'lib/actors/event_destination.rb', line 13

def initialize(input, output, sync = nil)
  self.input = input
  self.output = output
  @sync = sync || Sync[Event, matching_attributes: [:faculty, :source_type, :source_id, :absolute_sequence_number]].new
end

Instance Method Details

#generate_rowArray<Event>

Returns events synced to the database.

Returns:

  • (Array<Event>)

    events synced to the database


27
28
29
30
31
32
33
# File 'lib/actors/event_destination.rb', line 27

def generate_row
  if processed_row
    pop_processed_row
  else
    raise EndOfData
  end
end

#process_row(events) ⇒ Array<Event>

Returns events synced to the database.

Parameters:

  • events (Array<Event>)

    events that should be synced to the database

Returns:

  • (Array<Event>)

    events synced to the database


21
22
23
24
# File 'lib/actors/event_destination.rb', line 21

def process_row(events)
  @sync.perform(events: events)
  @sync.results[:events]
end