Class: CDC::SolidQueue::Runner
- Inherits:
-
Object
- Object
- CDC::SolidQueue::Runner
- Defined in:
- lib/cdc/solid_queue/runner.rb
Overview
Minimal ingestion runner boundary.
The runner accepts any stream object that yields PostgreSQL-derived CDC events. This keeps the class testable while production code can supply a pgoutput-client backed stream.
Instance Method Summary collapse
-
#initialize(stream:, enqueuer:) ⇒ Runner
constructor
A new instance of Runner.
-
#start ⇒ Integer
Start reading events and enqueueing jobs.
Constructor Details
#initialize(stream:, enqueuer:) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 17 18 |
# File 'lib/cdc/solid_queue/runner.rb', line 13 def initialize(stream:, enqueuer:) raise ArgumentError, 'stream must respond to #each' unless stream.respond_to?(:each) @stream = stream @enqueuer = enqueuer end |
Instance Method Details
#start ⇒ Integer
Start reading events and enqueueing jobs.
23 24 25 26 27 28 29 30 31 |
# File 'lib/cdc/solid_queue/runner.rb', line 23 def start count = 0 @stream.each do |event| result = @enqueuer.enqueue(event) checkpoint(event, result) count += 1 end count end |