Class: MedPipe::PipelinePlanProducer

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

Overview

prioryty が高いものから順に、並列数を踏まえて複数のPipelinePlanの状態をenqueuedに変更する

Instance Method Summary collapse

Constructor Details

#initialize(pipeline_group) ⇒ PipelinePlanProducer

Returns a new instance of PipelinePlanProducer.

Parameters:



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

def initialize(pipeline_group)
  @pipeline_group = pipeline_group
end

Instance Method Details

#runArray<MedPipe::PipelinePlan>

Returns Enqueued pipeline plans. 未実行ならnilを返す.

Returns:



11
12
13
14
15
16
17
18
# File 'lib/med_pipe/pipeline_plan_producer.rb', line 11

def run
  return if @pipeline_group.parallel_limit <= 0

  @pipeline_group.with_lock do
    enqueue_count = @pipeline_group.parallel_limit - @pipeline_group.pipeline_plans.active.count
    enqueue(enqueue_count) if enqueue_count.positive?
  end
end