Sha256: 040f32f55b9e0b3ffd81bf4199e1d058a9062df271ab0b1c392d53fd261ec05c

Contents?: true

Size: 1017 Bytes

Versions: 5

Compression:

Stored size: 1017 Bytes

Contents

module Isomorfeus
  module Operation
    class DeferredTask < LucidObject::Base
      STATES = %w[ready running failed]
      # when the task is added to the queue its added as ready
      # when its running, its running
      # when it failes, it failed, the exception attribute is filled
      # when it was successful, its removed from the queue
      attribute :operation_class_name, class: String, required: true, validate_block: proc { |v| raise 'Invalid Operation class!' unless Isomorfeus.valid_operation_class_name?(v) }
      attribute :props
      attribute :user_class_name, class: String, default: 'Anonymous'
      attribute :user_key, class: String, default: 'anonymous'
      attribute :state, class: String, required: true, index: :value, ensure: proc { |v| Isomorfeus::Operation::DeferredTask::STATES.include?(v) ? v : 'ready' }
      attribute :exception
      attribute :rtime

      def get_exception
        Marshal.load(exception) if exception
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
isomorfeus-operation-2.4.2 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-2.4.1 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-2.4.0 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-2.3.1 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-2.3.0 lib/isomorfeus/operation/deferred_task.rb