Class: CDC::Parallel::Runtime
- Inherits:
-
Object
- Object
- CDC::Parallel::Runtime
- Defined in:
- lib/cdc/parallel/runtime.rb
Overview
High-level Ractor runtime facade for cdc-core processors.
Instance Method Summary collapse
- #initialize(processor:, size: Etc.nprocessors, timeout: nil) ⇒ void constructor
-
#process(item) ⇒ CDC::Core::ProcessorResult
Process a ChangeEvent or TransactionEnvelope.
-
#process_transaction(transaction) ⇒ CDC::Core::ProcessorResult
Alias for transaction-oriented processing.
-
#shutdown ⇒ void
Shut down all runtime resources.
Constructor Details
#initialize(processor:, size: Etc.nprocessors, timeout: nil) ⇒ void
11 12 13 14 15 16 |
# File 'lib/cdc/parallel/runtime.rb', line 11 def initialize(processor:, size: Etc.nprocessors, timeout: nil) @processor_pool = ProcessorPool.new(processor:, size:, timeout:) @transaction_pool = TransactionPool.new(processor:, size:, timeout:) @router = Router.new(processor_pool: @processor_pool, transaction_pool: @transaction_pool) @shutdown = false end |
Instance Method Details
#process(item) ⇒ CDC::Core::ProcessorResult
Process a ChangeEvent or TransactionEnvelope.
22 23 24 25 26 |
# File 'lib/cdc/parallel/runtime.rb', line 22 def process(item) raise ShutdownError, "runtime has been shut down" if @shutdown @router.process(item) end |
#process_transaction(transaction) ⇒ CDC::Core::ProcessorResult
Alias for transaction-oriented processing.
32 33 34 |
# File 'lib/cdc/parallel/runtime.rb', line 32 def process_transaction(transaction) process(transaction) end |
#shutdown ⇒ void
This method returns an undefined value.
Shut down all runtime resources.
39 40 41 42 43 44 45 |
# File 'lib/cdc/parallel/runtime.rb', line 39 def shutdown return if @shutdown @shutdown = true @processor_pool.shutdown @transaction_pool.shutdown end |