Sha256: 31a107bc2ef82c0aded9c015a22bf56bec6793c1d0c53fffe9363a8b6d295614

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

module Trailblazer::V2_1
  class 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::V2_1::Activity::Path(
            name:             "taskWrap",
            normalizer_class: Magnetic::DefaultNormalizer,
            plus_poles:       Magnetic::PlusPoles.initial( :success => Magnetic::Builder::Path.default_outputs[:success] ) # DefaultNormalizer doesn't give us default PlusPoles.
          )

          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.invoke(activity, args, wrap_runtime: {}, **circuit_options)
        circuit_options = circuit_options.merge(
          runner:       TaskWrap::Runner,
          wrap_runtime: wrap_runtime,

          activity: { adds: [], circuit: {} }, # for Runner
        )

        # signal, (ctx, flow), circuit_options =
        Runner.(activity, args, circuit_options)
      end
    end # TaskWrap
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-future-2.1.0.rc1 lib/trailblazer/v2_1/activity/task_wrap.rb