Sha256: 494471b3bbe7184902a34a7f8d27b4e4c2a078c5356d5b93d68f31596f981f93

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

module EventSourcery
  module EventProcessing
    class ESPProcess
      def initialize(event_processor:,
                     event_source:,
                     subscription_master: EventStore::SignalHandlingSubscriptionMaster.new)
        @event_processor = event_processor
        @event_source = event_source
        @subscription_master = subscription_master
      end

      def start
        name_process
        error_handler.with_error_handling do
          EventSourcery.logger.info("Starting #{processor_name}")
          subscribe_to_event_stream
          EventSourcery.logger.info("Stopping #{@event_processor.processor_name}")
        end
      end

      private

      def processor_name
        @event_processor.processor_name.to_s
      end

      def error_handler
        @error_handler ||= EventSourcery.config.error_handler_class.new(processor_name: processor_name)
      end

      def name_process
        Process.setproctitle(@event_processor.class.name)
      end

      def subscribe_to_event_stream
        @event_processor.subscribe_to(@event_source,
                                      subscription_master: @subscription_master)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
event_sourcery-0.14.0 lib/event_sourcery/event_processing/esp_process.rb
event_sourcery-0.13.0 lib/event_sourcery/event_processing/esp_process.rb