Sha256: d8dd555bf4faa8407e940d2385f7d7b8d48db961eb8d2aecb3da8ab1607a3f98

Contents?: true

Size: 1.12 KB

Versions: 40

Compression:

Stored size: 1.12 KB

Contents

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

40 entries across 40 versions & 1 rubygems

Version Path
dynflow-1.3.0 lib/dynflow/director/flow_manager.rb
dynflow-1.2.3 lib/dynflow/director/flow_manager.rb
dynflow-1.2.2 lib/dynflow/director/flow_manager.rb
dynflow-1.2.1 lib/dynflow/director/flow_manager.rb
dynflow-1.2.0 lib/dynflow/director/flow_manager.rb
dynflow-1.2.0.pre1 lib/dynflow/director/flow_manager.rb
dynflow-1.1.6 lib/dynflow/director/flow_manager.rb
dynflow-1.1.5 lib/dynflow/director/flow_manager.rb
dynflow-1.1.4 lib/dynflow/director/flow_manager.rb
dynflow-1.1.3 lib/dynflow/director/flow_manager.rb
dynflow-1.1.2 lib/dynflow/director/flow_manager.rb
dynflow-1.1.1 lib/dynflow/director/flow_manager.rb
dynflow-1.1.0 lib/dynflow/director/flow_manager.rb
dynflow-1.0.5 lib/dynflow/director/flow_manager.rb
dynflow-1.0.4 lib/dynflow/director/flow_manager.rb
dynflow-1.0.3 lib/dynflow/director/flow_manager.rb
dynflow-1.0.2 lib/dynflow/director/flow_manager.rb
dynflow-1.0.1 lib/dynflow/director/flow_manager.rb
dynflow-1.0.0 lib/dynflow/director/flow_manager.rb
dynflow-0.8.37 lib/dynflow/director/flow_manager.rb