Sha256: 10df2b9b30ee69e0d3e2af5ebc5aa22a0f5837a636497a944ce6c853122c9263

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

module Isomorfeus
  module Operation
    class DeferredTask < LucidObject
      STATES = %w[ready running failed]

      query :ready, 'state:"ready"'
      query :running, 'state:"running"'
      query :failed, 'state:"failed"'
      query :all, 'state:*'

      # 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: :yes, 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

8 entries across 8 versions & 1 rubygems

Version Path
isomorfeus-operation-22.9.0.rc8 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc7 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc6 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc5 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc4 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc3 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc2 lib/isomorfeus/operation/deferred_task.rb
isomorfeus-operation-22.9.0.rc1 lib/isomorfeus/operation/deferred_task.rb