Class: PgEventstore::EventsProcessorHandlers

Inherits:
Object
  • Object
show all
Includes:
PgEventstore::Extensions::CallbackHandlersExtension
Defined in:
lib/pg_eventstore/subscriptions/callback_handlers/events_processor_handlers.rb

Class Method Summary collapse

Methods included from PgEventstore::Extensions::CallbackHandlersExtension

included

Class Method Details

.after_runner_died(callbacks, error) ⇒ void

This method returns an undefined value.

Parameters:



27
28
29
# File 'lib/pg_eventstore/subscriptions/callback_handlers/events_processor_handlers.rb', line 27

def after_runner_died(callbacks, error)
  callbacks.run_callbacks(:error, error)
end

.before_runner_restored(callbacks) ⇒ void

This method returns an undefined value.

Parameters:



33
34
35
# File 'lib/pg_eventstore/subscriptions/callback_handlers/events_processor_handlers.rb', line 33

def before_runner_restored(callbacks)
  callbacks.run_callbacks(:restart)
end

.change_state(callbacks, state) ⇒ void

This method returns an undefined value.

Parameters:



40
41
42
# File 'lib/pg_eventstore/subscriptions/callback_handlers/events_processor_handlers.rb', line 40

def change_state(callbacks, state)
  callbacks.run_callbacks(:change_state, state)
end

.process_event(callbacks, handler, raw_events) ⇒ void

This method returns an undefined value.

Parameters:



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pg_eventstore/subscriptions/callback_handlers/events_processor_handlers.rb', line 12

def process_event(callbacks, handler, raw_events)
  raw_event = raw_events.shift
  return sleep 0.5 if raw_event.nil?

  callbacks.run_callbacks(:process, Utils.original_global_position(raw_event)) do
    handler.call(raw_event)
  end
rescue
  raw_events.unshift(raw_event)
  raise
end