Sha256: 723d8e004dbd2f353159f0da5e7f2666d7462cbe2c485d28fe9d1783951f787e

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
module Dynflow
  class Director
    class FlowManager
      include Algebrick::TypeCheck

      attr_reader :execution_plan, :cursor_index

      def initialize(execution_plan, flow)
        @execution_plan = Type! execution_plan, ExecutionPlan
        @flow           = flow
        @cursor_index   = {}
        @cursor         = build_root_cursor
      end

      def done?
        @cursor.done?
      end

      # @return [Set] of steps to continue with
      def what_is_next(flow_step)
        return [] if flow_step.state == :suspended

        success = flow_step.state != :error
        return cursor_index[flow_step.id].what_is_next(flow_step, success)
      end

      # @return [Set] of steps to continue with
      def start
        return @cursor.what_is_next.tap do |steps|
          raise 'invalid state' if steps.empty? && !done?
        end
      end

      private

      def build_root_cursor
        # the root cursor has to always run against sequence
        sequence = @flow.is_a?(Flows::Sequence) ? @flow : Flows::Sequence.new([@flow])
        return SequenceCursor.new(self, sequence, nil)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
dynflow-1.8.2 lib/dynflow/director/flow_manager.rb
dynflow-1.8.1 lib/dynflow/director/flow_manager.rb
dynflow-1.8.0 lib/dynflow/director/flow_manager.rb
dynflow-1.7.0 lib/dynflow/director/flow_manager.rb
dynflow-1.6.11 lib/dynflow/director/flow_manager.rb
dynflow-1.6.10 lib/dynflow/director/flow_manager.rb
dynflow-1.6.8 lib/dynflow/director/flow_manager.rb
dynflow-1.6.7 lib/dynflow/director/flow_manager.rb
dynflow-1.6.6 lib/dynflow/director/flow_manager.rb
dynflow-1.6.5 lib/dynflow/director/flow_manager.rb
dynflow-1.6.4 lib/dynflow/director/flow_manager.rb
dynflow-1.6.3 lib/dynflow/director/flow_manager.rb
dynflow-1.6.2 lib/dynflow/director/flow_manager.rb
dynflow-1.6.1 lib/dynflow/director/flow_manager.rb
dynflow-1.4.9 lib/dynflow/director/flow_manager.rb
dynflow-1.4.8 lib/dynflow/director/flow_manager.rb
dynflow-1.5.0 lib/dynflow/director/flow_manager.rb
dynflow-1.4.7 lib/dynflow/director/flow_manager.rb
dynflow-1.4.6 lib/dynflow/director/flow_manager.rb
dynflow-1.4.5 lib/dynflow/director/flow_manager.rb