Class: Sq::Dbsync::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/sq/dbsync/pipeline.rb,
lib/sq/dbsync/pipeline/simple_context.rb,
lib/sq/dbsync/pipeline/threaded_context.rb

Overview

See lib/sq/dbsync/pipeline.rb

Defined Under Namespace

Classes: Failure, SimpleContext, ThreadedContext

Instance Method Summary collapse

Constructor Details

#initialize(tasks, *stages) ⇒ Pipeline

Returns a new instance of Pipeline.



33
34
35
36
# File 'lib/sq/dbsync/pipeline.rb', line 33

def initialize(tasks, *stages)
  self.tasks  = tasks
  self.stages = stages
end

Instance Method Details

#run(context = ThreadedContext) ⇒ Object

Run the pipeline and return the computed results.

context - The computational context in which to run the pipeline. Must

respond to `#call` and take tasks, stages, and a processing
lambda as arguments. By default runs the pipeline in parallel,
but an alternative `SimpleContext` is provided to run in a
single thread to aid debugging and testing.


45
46
47
48
49
# File 'lib/sq/dbsync/pipeline.rb', line 45

def run(context = ThreadedContext)
  context.call(tasks, stages, ->(stage, result) {
    process(stage, result)
  })
end