Class: Akasha::AsyncEventRouter
- Inherits:
-
EventRouterBase
- Object
- EventRouterBase
- Akasha::AsyncEventRouter
- Defined in:
- lib/akasha/async_event_router.rb
Overview
Event router working that can run in the background, providing eventual consistency. Can use the same EventListeners as the synchronous EventRouter.
Constant Summary collapse
- DEFAULT_POLL_SECONDS =
2- DEFAULT_PAGE_SIZE =
20- DEFAULT_PROJECTION_STREAM =
'AsyncEventRouter'.freeze
- DEFAULT_CHECKPOINT_STRATEGY =
Akasha::Checkpoint::HttpEventStoreCheckpoint
Instance Method Summary collapse
Methods inherited from EventRouterBase
#initialize, #register_event_listener, #route
Constructor Details
This class inherits a constructor from Akasha::EventRouterBase
Instance Method Details
#connect!(repository, projection_name: DEFAULT_PROJECTION_STREAM, checkpoint_strategy: DEFAULT_CHECKPOINT_STRATEGY, page_size: DEFAULT_PAGE_SIZE, poll: DEFAULT_POLL_SECONDS) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/akasha/async_event_router.rb', line 13 def connect!(repository, projection_name: DEFAULT_PROJECTION_STREAM, checkpoint_strategy: DEFAULT_CHECKPOINT_STRATEGY, page_size: DEFAULT_PAGE_SIZE, poll: DEFAULT_POLL_SECONDS) projection_stream = repository.store.streams[projection_name] checkpoint = checkpoint_strategy.is_a?(Class) ? checkpoint_strategy.new(projection_stream) : checkpoint_strategy repository.merge_all_by_event(into: projection_name, only: registered_event_names) Thread.new do run_forever(projection_stream, checkpoint, page_size, poll) end end |