Class: CDC::Concurrent::Runtime
- Inherits:
-
Object
- Object
- CDC::Concurrent::Runtime
- Defined in:
- lib/cdc/concurrent/runtime.rb
Overview
High-level concurrent runtime facade for cdc-core processors.
Runtime owns the public lifecycle for cdc-concurrent. It wires together the event processor pool, transaction pool, and router so callers can submit individual events, batches, or transaction envelopes through one object.
Instance Method Summary collapse
-
#initialize(processor:, concurrency: 100, timeout: nil, preserve_order: true) ⇒ void
constructor
Builds a concurrent runtime for one processor.
-
#process(item) ⇒ CDC::Core::ProcessorResult+
Processes a supported work item through the runtime router.
-
#process_many(events) ⇒ Array<CDC::Core::ProcessorResult>
Processes a batch of change events.
-
#process_transaction(transaction) ⇒ CDC::Core::ProcessorResult
Processes a transaction envelope as one logical work item.
-
#shutdown ⇒ void
Shuts down the runtime and its underlying pools.
Constructor Details
#initialize(processor:, concurrency: 100, timeout: nil, preserve_order: true) ⇒ void
Builds a concurrent runtime for one processor.
19 20 21 22 23 24 |
# File 'lib/cdc/concurrent/runtime.rb', line 19 def initialize(processor:, concurrency: 100, timeout: nil, preserve_order: true) @processor_pool = ProcessorPool.new(processor:, concurrency:, timeout:, preserve_order:) @transaction_pool = TransactionPool.new(processor:, concurrency:, timeout:, preserve_order:) @router = Router.new(processor_pool: @processor_pool, transaction_pool: @transaction_pool) @shutdown = false end |
Instance Method Details
#process(item) ⇒ CDC::Core::ProcessorResult+
Processes a supported work item through the runtime router.
33 34 35 36 37 |
# File 'lib/cdc/concurrent/runtime.rb', line 33 def process(item) raise ShutdownError, "runtime has been shut down" if @shutdown @router.process(item) end |
#process_many(events) ⇒ Array<CDC::Core::ProcessorResult>
Processes a batch of change events.
43 44 45 |
# File 'lib/cdc/concurrent/runtime.rb', line 43 def process_many(events) process(events) end |
#process_transaction(transaction) ⇒ CDC::Core::ProcessorResult
Processes a transaction envelope as one logical work item.
52 53 54 |
# File 'lib/cdc/concurrent/runtime.rb', line 52 def process_transaction(transaction) process(transaction) end |
#shutdown ⇒ void
This method returns an undefined value.
Shuts down the runtime and its underlying pools.
59 60 61 62 63 64 65 |
# File 'lib/cdc/concurrent/runtime.rb', line 59 def shutdown return if @shutdown @shutdown = true @processor_pool.shutdown @transaction_pool.shutdown end |