Class: Ocak::PipelineRunner

Inherits:
Object
  • Object
show all
Includes:
Planner, Verification
Defined in:
lib/ocak/pipeline_runner.rb

Defined Under Namespace

Classes: StepContext

Constant Summary

Constants included from Planner

Ocak::Planner::STEP_PROMPTS

Instance Method Summary collapse

Methods included from Planner

#build_step_prompt, #parse_planner_output, #plan_batches, #sequential_batches

Methods included from Verification

#lint_extensions_for, #run_final_checks, #run_scoped_lint

Constructor Details

#initialize(config:, options: {}) ⇒ PipelineRunner

Returns a new instance of PipelineRunner.



17
18
19
20
21
22
23
24
# File 'lib/ocak/pipeline_runner.rb', line 17

def initialize(config:, options: {})
  @config = config
  @options = options
  @watch_formatter = options[:watch] ? WatchFormatter.new : nil
  @shutting_down = false
  @active_issues = []
  @active_mutex = Mutex.new
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
# File 'lib/ocak/pipeline_runner.rb', line 26

def run
  if @options[:single]
    run_single(@options[:single])
  else
    run_loop
  end
end

#shutdown!Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ocak/pipeline_runner.rb', line 34

def shutdown!
  @shutting_down = true
  logger = build_logger
  logger.info('Graceful shutdown initiated...')

  # Transition any in-progress issues back to ready
  issues = IssueFetcher.new(config: @config, logger: logger)
  @active_mutex.synchronize do
    @active_issues.each do |issue_number|
      logger.info("Returning issue ##{issue_number} to ready queue")
      issues.transition(issue_number, from: @config.label_in_progress, to: @config.label_ready)
    rescue StandardError => e
      logger.warn("Failed to reset issue ##{issue_number}: #{e.message}")
    end
  end
end