Sha256: a32e490ce70d7f0b3724d3d25eef0a44da3dc8d2baa6f111671d0d77136809df
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true module Attr module Gather module Workflow # A wrapper containing information and results of a task execution # # @!attribute [r] started_at # @return [Time] time which the execution occured # # @!attribute [r] task # @return [Attr::Gather::Workflow::Task] task that was run # # @!attribute [r] result # @return [Concurrent::Promise] the result promise of the the task # # @api public class TaskExecutionResult include Concerns::Identifiable attr_reader :task, :result, :started_at, :uuid def initialize(task, result) @started_at = Time.now @uuid = SecureRandom.uuid @task = task @result = result end # @!attribute [r] state # @return [:unscheduled, :pending, :processing, :rejected, :fulfilled] def state result.state end # Extracts the result, this is an unsafe operation that blocks the # operation, and returns either the value or an exception. # # @note For more information, check out {https://ruby-concurrency.github.io/concurrent-ruby/1.1.5/Concurrent/Concern/Obligation.html#value!-instance_method} def value! result.value! end # Represents the TaskExecutionResult as a hash # # @return [Hash] def as_json value = result.value { started_at: started_at, task: task.as_json, state: state, value: value } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems