Class: MedPipe::PipelinePlanConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/med_pipe/pipeline_plan_consumer.rb

Overview

enqueued な pipeline plan を1つ取得 & 実行

Instance Method Summary collapse

Constructor Details

#initialize(pipeline_group:, pipeline_runner:) ⇒ PipelinePlanConsumer

Returns a new instance of PipelinePlanConsumer.

Parameters:

  • pipeline_runner (Proc)

    pipeline plan から pipeline を作成し実行する



6
7
8
9
# File 'lib/med_pipe/pipeline_plan_consumer.rb', line 6

def initialize(pipeline_group:, pipeline_runner:)
  @pipeline_group = pipeline_group
  @pipeline_runner = pipeline_runner
end

Instance Method Details

#runPipelinePlan

Returns 実行した pipeline plan。なければ nil.

Returns:

  • (PipelinePlan)

    実行した pipeline plan。なければ nil



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/med_pipe/pipeline_plan_consumer.rb', line 12

def run
  pipeline_plan = fetch_and_run_pipeline_plan
  return nil if pipeline_plan.nil?

  @pipeline_runner.call(pipeline_plan)
  complete_pipeline_plan(pipeline_plan)
  pipeline_plan
rescue StandardError => e
  error_pipeline_plan(pipeline_plan)
  raise e
end