Sha256: e5c801cdb9ad8538f862fed1638c57f336870c1c22a89e5dbd08825fef885cfd

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

class Trailblazer::V2_1::Activity < Module
  module TaskWrap
    # TaskWrap tasks for tracing.
    module Trace
      module_function

      # taskWrap step to capture incoming arguments of a step.
      # def self.capture_args(direction, options, flow_options, wrap_config, original_flow_options)
      def capture_args((wrap_config, original_args), **circuit_options)

        original_args = capture_for(wrap_config[:task], *original_args)

        return Trailblazer::V2_1::Activity::Right, [wrap_config, original_args], circuit_options
      end

      # taskWrap step to capture outgoing arguments from a step.
      def capture_return((wrap_config, original_args), **circuit_options)
        (original_options, original_flow_options, _) = original_args[0]

        original_flow_options[:stack] << Trailblazer::V2_1::Activity::Trace::Entity::Output.new(
          wrap_config[:task], {}, wrap_config[:return_signal]
        ).freeze

        original_flow_options[:stack].unindent!


        return Trailblazer::V2_1::Activity::Right, [wrap_config, original_args], circuit_options
      end

      # It's important to understand that {flow[:stack]} is mutated by design. This is needed so
      # in case of exceptions we still have a "global" trace - unfortunately Ruby doesn't allow
      # us a better way.
      def capture_for(task, (ctx, flow), activity:, **circuit_options)
        flow[:stack].indent!

        flow[:stack] << Trailblazer::V2_1::Activity::Trace::Entity::Input.new(
          task, activity
        ).freeze

        return [ctx, flow], circuit_options.merge(activity: activity)
      end
    end
  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/trace.rb