Class: EventSourcery::EventProcessing::ESPProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/event_sourcery/event_processing/esp_process.rb

Constant Summary collapse

DEFAULT_AFTER_FORK =
-> (event_processor) { }

Instance Method Summary collapse

Constructor Details

#initialize(event_processor:, event_source:, subscription_master: EventStore::SignalHandlingSubscriptionMaster.new, after_fork: nil) ⇒ ESPProcess

Returns a new instance of ESPProcess.



6
7
8
9
10
11
12
13
14
# File 'lib/event_sourcery/event_processing/esp_process.rb', line 6

def initialize(event_processor:,
               event_source:,
               subscription_master: EventStore::SignalHandlingSubscriptionMaster.new,
               after_fork: nil)
  @event_processor = event_processor
  @event_source = event_source
  @subscription_master = subscription_master
  @after_fork = after_fork || DEFAULT_AFTER_FORK
end

Instance Method Details

#startObject

This will start the Event Stream Processor which will subscribe to the event stream source.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/event_sourcery/event_processing/esp_process.rb', line 18

def start
  name_process
  @after_fork.call(@event_processor)
  error_handler.with_error_handling do
    EventSourcery.logger.info("Starting #{processor_name}")
    subscribe_to_event_stream
    EventSourcery.logger.info("Stopping #{processor_name}")
  end
rescue Exception => e
  EventSourcery.logger.fatal("An unhandled exception occurred in #{processor_name}")
  EventSourcery.logger.fatal(e)
  EventSourcery.config.on_event_processor_critical_error.call(e, processor_name)
  raise e
end