Sha256: 01d5bb67e8a60de777a0a54ec8026776915ccd7b482a74dcb10ee1454371cc10

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

module Trailblazer
  class Activity
    #
    # 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
      module_function

      # Compute runtime arguments necessary to execute a taskWrap per task of the activity.
      # This method is the top-level entry, called only once for the entire activity graph.
      # [:wrap_static] The taskWrap used for the topmost activity/operation.
      def invoke(activity, args, wrap_runtime: {}, wrap_static: initial_wrap_static, **circuit_options) # FIXME: why do we need this method?
        circuit_options = circuit_options.merge(
          runner:       TaskWrap::Runner,
          wrap_runtime: wrap_runtime,
          # This {:activity} structure is currently (?) only needed in {TaskWrap.wrap_static_for}, where we
          # access {activity[:wrap_static]} to compile the effective taskWrap.
          activity:     {wrap_static: {activity => wrap_static}, nodes: {}}, # for Runner. Ideally we'd have a list of all static_wraps here (even nested).
        )

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

      # {:extension} API
      # Extend the static taskWrap from a macro or DSL call.
      # Gets executed in {Intermediate.call} which also provides {config}.

      def initial_wrap_static(*)
        Pipeline.new([Pipeline.Row("task_wrap.call_task", TaskWrap.method(:call_task))])
      end
    end # TaskWrap
  end
end
require "trailblazer/activity/task_wrap/pipeline"
require "trailblazer/activity/task_wrap/call_task"
require "trailblazer/activity/task_wrap/runner"
require "trailblazer/activity/task_wrap/extension"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trailblazer-activity-0.14.0 lib/trailblazer/activity/task_wrap.rb
trailblazer-activity-0.14.0.beta2 lib/trailblazer/activity/task_wrap.rb
trailblazer-activity-0.14.0.beta1 lib/trailblazer/activity/task_wrap.rb