Class: Massive::Job
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Cancelling
#cancelling
Methods included from Retry
#retrying
#elapsed_time
#current_memory_consumption
Methods included from Status
#completed?, #enqueued?, #failed?, #start!, #started?
Class Method Details
24
25
26
|
# File 'lib/massive/job.rb', line 24
def self.perform(process_id, step_id, job_id)
Massive::Process.find_job(process_id, step_id, job_id).work
end
|
.queue ⇒ Object
28
29
30
|
# File 'lib/massive/job.rb', line 28
def self.queue
:massive_job
end
|
Instance Method Details
#each_item(&block) ⇒ Object
64
65
66
|
# File 'lib/massive/job.rb', line 64
def each_item(&block)
end
|
#enqueue ⇒ Object
32
33
34
|
# File 'lib/massive/job.rb', line 32
def enqueue
Resque.enqueue(self.class, process.id.to_s, step.id.to_s, id.to_s)
end
|
#finish! ⇒ Object
58
59
60
61
62
|
# File 'lib/massive/job.rb', line 58
def finish!
update_attributes(finished_at: Time.now, memory_consumption: current_memory_consumption)
step.complete
end
|
#process_each(item, index) ⇒ Object
68
69
70
|
# File 'lib/massive/job.rb', line 68
def process_each(item, index)
end
|
#work ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/massive/job.rb', line 36
def work
handle_errors do
cancelling do
start!
run_callbacks :work do
each_item do |item, index|
retrying do
cancelling do
process_each(item, index)
increment_processed
notify(:progress)
end
end
end
end
finish!
end
end
end
|