Class: CDC::Concurrent::Router
- Inherits:
-
Object
- Object
- CDC::Concurrent::Router
- Defined in:
- lib/cdc/concurrent/router.rb
Overview
Routes CDC work items to the appropriate concurrent execution pool.
Router is intentionally small. It keeps Runtime focused on lifecycle while preserving the distinction between individual events, transaction envelopes, and event batches.
Instance Method Summary collapse
-
#initialize(processor_pool:, transaction_pool:) ⇒ void
constructor
Builds a router using existing processor and transaction pools.
-
#process(item) ⇒ CDC::Core::ProcessorResult+
Dispatches a supported work item to its matching pool.
Constructor Details
#initialize(processor_pool:, transaction_pool:) ⇒ void
Builds a router using existing processor and transaction pools.
16 17 18 19 |
# File 'lib/cdc/concurrent/router.rb', line 16 def initialize(processor_pool:, transaction_pool:) @processor_pool = processor_pool @transaction_pool = transaction_pool end |
Instance Method Details
#process(item) ⇒ CDC::Core::ProcessorResult+
Dispatches a supported work item to its matching pool.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cdc/concurrent/router.rb', line 27 def process(item) case item when CDC::Core::ChangeEvent @processor_pool.process(item) when CDC::Core::TransactionEnvelope @transaction_pool.process(item) when Array @processor_pool.process_many(item) else raise UnsupportedWorkItemError, "unsupported CDC work item: #{item.class}" end end |