Sha256: cc626eaf09ee497e039cd938ae4d19c9db5c1e5bfdd5779fa524b7a80853bd69

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

class Trailblazer::Activity < Module
    #
    # Example with tracing:
    #
          # Call the task_wrap circuit:
        #   |-- Start
        #   |-- Trace.capture_args   [optional]
        #   |-- Call (call actual task) id: "task_wrap.call_task"
        #   |-- Trace.capture_return [optional]
        #   |-- Wrap::End
  module TaskWrap
    # The actual activity that implements the taskWrap.
    def self.initial_activity
      Module.new do
        extend Trailblazer::Activity::Path( name: "taskWrap", normalizer_class: Magnetic::DefaultNormalizer )

        task TaskWrap.method(:call_task), id: "task_wrap.call_task" # ::call_task is defined in task_wrap/call_task.
      end
    end

    # Compute runtime arguments necessary to execute a taskWrap per task of the activity.
    def self.arguments_for_call(activity, (options, flow_options), **circuit_options)
      circuit_options = circuit_options.merge(
        runner:       TaskWrap::Runner,
        wrap_runtime: circuit_options[:wrap_runtime] || {},
        wrap_static:  activity[:wrap_static] || {},
      )

      return activity, [ options, flow_options ], circuit_options
    end

    module NonStatic
      def self.arguments_for_call(activity, (options, flow_options), **circuit_options)
        circuit_options = circuit_options.merge(
          runner:       TaskWrap::Runner,
          wrap_runtime: circuit_options[:wrap_runtime] || {}, # FIXME:this sucks. (was:) this overwrites wrap_runtime from outside.
          wrap_static:  ::Hash.new(TaskWrap.initial_activity), # add a default static wrap.
        )

        return activity, [ options, flow_options ], circuit_options
      end
    end

    # better: MyClass < Activity(TaskWrap, ...)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trailblazer-activity-0.4.2 lib/trailblazer/activity/task_wrap.rb
trailblazer-activity-0.4.1 lib/trailblazer/activity/task_wrap.rb
trailblazer-activity-0.4.0 lib/trailblazer/activity/task_wrap.rb
trailblazer-activity-0.4.o lib/trailblazer/activity/task_wrap.rb