Class: PerfectQueue::AcquiredTask

Inherits:
TaskWithMetadata show all
Defined in:
lib/perfectqueue/task.rb

Instance Attribute Summary

Attributes included from TaskMetadataAccessors

#attributes

Attributes inherited from Task

#key

Attributes included from Model

#client

Instance Method Summary collapse

Methods inherited from TaskWithMetadata

#inspect

Methods included from TaskMetadataAccessors

#cancel_requested?, #created_at, #data, #finished?, #message, #running?, #status, #timeout, #type, #user, #waiting?

Methods inherited from Task

#cancel_request!, #exists?, #force_finish!, #inspect, #metadata, #preempt

Methods included from Model

#config

Constructor Details

#initialize(client, key, attributes, task_token) ⇒ AcquiredTask

Returns a new instance of AcquiredTask.



72
73
74
75
# File 'lib/perfectqueue/task.rb', line 72

def initialize(client, key, attributes, task_token)
  super(client, key, attributes)
  @task_token = task_token
end

Instance Method Details

#finish!(options = {}) ⇒ Object



81
82
83
# File 'lib/perfectqueue/task.rb', line 81

def finish!(options={})
  @client.finish(@task_token, options)
end

#heartbeat!(options = {}) ⇒ Object



77
78
79
# File 'lib/perfectqueue/task.rb', line 77

def heartbeat!(options={})
  @client.heartbeat(@task_token, options)
end

#release!(options = {}) ⇒ Object



85
86
87
# File 'lib/perfectqueue/task.rb', line 85

def release!(options={})
  @client.release(@task_token, options)
end

#retry!(options = {}) ⇒ Object



89
90
91
# File 'lib/perfectqueue/task.rb', line 89

def retry!(options={})
  @client.retry(@task_token, options)
end

#update_data!(hash) ⇒ Object



93
94
95
96
97
98
# File 'lib/perfectqueue/task.rb', line 93

def update_data!(hash)
  data = @attributes[:data] || {}
  merged = data.merge(hash)
  heartbeat!(:data => merged)
  @attributes[:data] = merged
end