Sha256: a0a17e0a5dc2861dd9ce58ae8118a27d56c7050d9c1ca6e6c54061dbf9f2e19e

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 Bytes

Contents

# frozen_string_literal: true

require 'concurrent'
require 'attr/gather/workflow/task_execution_result'

module Attr
  module Gather
    module Workflow
      # @api private
      class TaskExecutor
        attr_reader :batch, :container, :executor

        def initialize(batch, container:)
          @batch = batch
          @container = container
          @executor = :immediate
        end

        def call(input)
          batch.map do |task|
            task_proc = container.resolve(task.name)
            result = Concurrent::Promise.execute(executor: executor) do
              task_proc.call(input)
            end
            TaskExecutionResult.new(task, result)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attr-gather-1.1.3 lib/attr/gather/workflow/task_executor.rb
attr-gather-1.1.2 lib/attr/gather/workflow/task_executor.rb
attr-gather-1.1.1 lib/attr/gather/workflow/task_executor.rb
attr-gather-1.1.0 lib/attr/gather/workflow/task_executor.rb
attr-gather-1.0.0 lib/attr/gather/workflow/task_executor.rb