Class: CDC::Sidekiq::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/cdc/sidekiq/runtime.rb

Overview

Executes a CDC processor through one of the CDC runtime primitives.

Runtime is intentionally selected outside Sidekiq’s own concurrency setting. Sidekiq concurrency controls how many jobs run at once. This object controls how one CDC-aware job fans work out internally.

Defined Under Namespace

Classes: DirectPool

Instance Method Summary collapse

Constructor Details

#initialize(processor:, runtime:, parallel_size:, concurrency:, timeout:, preserve_order:) ⇒ void

Parameters:

  • processor (Object)

    CDC processor object that responds to #process.

  • runtime (Symbol)

    execution runtime, currently :parallel, :concurrent, or :direct.

  • parallel_size (Integer)

    number of Ractors used by cdc-parallel.

  • concurrency (Integer)

    number of Async tasks used by cdc-concurrent.

  • timeout (Float, nil)

    optional timeout passed to the selected runtime.

  • preserve_order (Boolean)

    whether cdc-concurrent should preserve input order.



18
19
20
21
22
23
24
25
# File 'lib/cdc/sidekiq/runtime.rb', line 18

def initialize(processor:, runtime:, parallel_size:, concurrency:, timeout:, preserve_order:)
  @processor = processor
  @runtime = runtime.to_sym
  @parallel_size = parallel_size
  @concurrency = concurrency
  @timeout = timeout
  @preserve_order = preserve_order
end

Instance Method Details

#process(item) ⇒ Object

Process one work item through the selected runtime.

Parameters:

  • item (Object)

    work item passed to the processor.

Returns:

  • (Object)

    processor result returned by the selected runtime.



31
32
33
# File 'lib/cdc/sidekiq/runtime.rb', line 31

def process(item)
  with_pool { |pool| pool.process(item) }
end

#process_many(items) ⇒ Array<Object>

Process many work items through the selected runtime.

Parameters:

  • items (Array<Object>)

    work items passed to the processor.

Returns:

  • (Array<Object>)

    processor results returned by the selected runtime.



39
40
41
# File 'lib/cdc/sidekiq/runtime.rb', line 39

def process_many(items)
  with_pool { |pool| pool.process_many(items) }
end