Class: TransactionalOutbox::Relay::EventProcessor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, producer) ⇒ EventProcessor

Returns a new instance of EventProcessor.



8
9
10
11
12
# File 'lib/transactional_outbox/relay/event_processor.rb', line 8

def initialize(queue, producer)
  @queue = queue
  @db = TransactionalOutbox::Database.new
  @producer = producer
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



6
7
8
# File 'lib/transactional_outbox/relay/event_processor.rb', line 6

def db
  @db
end

#producerObject (readonly)

Returns the value of attribute producer.



6
7
8
# File 'lib/transactional_outbox/relay/event_processor.rb', line 6

def producer
  @producer
end

#queueObject (readonly)

Returns the value of attribute queue.



6
7
8
# File 'lib/transactional_outbox/relay/event_processor.rb', line 6

def queue
  @queue
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/transactional_outbox/relay/event_processor.rb', line 14

def call
  process
rescue StandardError => e
  TransactionalOutbox::Relay.monitor.publish(
    TransactionalOutbox::WORKER_EXCEPTIONS_TOTAL_MONITOR_EVENT,
    { queue:, exception: e.class.to_s }
  )

  resolve_failover.call(e, @events)
end