Class: CDC::Parallel::TransactionPool
- Inherits:
-
Object
- Object
- CDC::Parallel::TransactionPool
- Defined in:
- lib/cdc/parallel/transaction_pool.rb
Overview
Processes a TransactionEnvelope as a single ordering-preserving unit.
Instance Method Summary collapse
-
#initialize(processor:, size: Etc.nprocessors, timeout: nil) ⇒ TransactionPool
constructor
A new instance of TransactionPool.
-
#process(transaction) ⇒ CDC::Core::ProcessorResult
Process all events inside a transaction envelope.
-
#shutdown ⇒ void
Shut down worker resources.
Constructor Details
#initialize(processor:, size: Etc.nprocessors, timeout: nil) ⇒ TransactionPool
Returns a new instance of TransactionPool.
10 11 12 |
# File 'lib/cdc/parallel/transaction_pool.rb', line 10 def initialize(processor:, size: Etc.nprocessors, timeout: nil) @processor_pool = ProcessorPool.new(processor:, size:, timeout:) end |
Instance Method Details
#process(transaction) ⇒ CDC::Core::ProcessorResult
Process all events inside a transaction envelope.
18 19 20 21 |
# File 'lib/cdc/parallel/transaction_pool.rb', line 18 def process(transaction) results = transaction.events.map { |event| @processor_pool.process(event) }.freeze ResultCollector.normalize(results) end |
#shutdown ⇒ void
This method returns an undefined value.
Shut down worker resources.
26 27 28 |
# File 'lib/cdc/parallel/transaction_pool.rb', line 26 def shutdown @processor_pool.shutdown end |