Class: Riffer::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/riffer/runner.rb

Overview

Generic concurrency primitive for batch execution.

Subclasses implement map to control how items are processed (sequentially, threaded, etc.).

runner = Riffer::Runner::Sequential.new
runner.map([1, 2, 3], context: ctx) { |n| n * 2 }
# => [2, 4, 6]

Direct Known Subclasses

Fibers, Sequential, Threaded

Defined Under Namespace

Classes: Fibers, Sequential, Threaded

Instance Method Summary collapse

Instance Method Details

#map(items, context:, &block) ⇒ Object

Maps over items using the provided block.

items

the items to process.

context

context hash forwarded from the agent.

Raises NotImplementedError if not implemented by subclass.

– : (Array, context: Hash[Symbol, untyped]?) { (untyped) -> untyped } -> Array

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/riffer/runner.rb', line 23

def map(items, context:, &block)
  raise NotImplementedError, "#{self.class} must implement #map"
end