Class: Rector::Job
- Inherits:
-
Object
show all
- Defined in:
- lib/rector/job.rb
Defined Under Namespace
Classes: WorkerCollection
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Job
Returns a new instance of Job.
23
24
25
26
|
# File 'lib/rector/job.rb', line 23
def initialize
@workers = WorkerCollection.new(self)
@backend = Rector.backend_for(id)
end
|
Instance Attribute Details
#workers ⇒ Object
Returns the value of attribute workers.
21
22
23
|
# File 'lib/rector/job.rb', line 21
def workers
@workers
end
|
Instance Method Details
#allocate_worker_id ⇒ Object
34
35
36
37
38
|
# File 'lib/rector/job.rb', line 34
def allocate_worker_id
"#{id}:#{SecureRandom.hex(8)}"
end
|
#cleanup ⇒ Object
50
51
52
|
# File 'lib/rector/job.rb', line 50
def cleanup
@backend.cleanup
end
|
#data ⇒ Object
46
47
48
|
# File 'lib/rector/job.rb', line 46
def data
@data ||= @backend.read_job_data_to_hash
end
|
#id ⇒ Object
28
29
30
31
32
|
# File 'lib/rector/job.rb', line 28
def id
@id ||= SecureRandom.hex(10)
end
|
#join ⇒ Object
40
41
42
43
44
|
# File 'lib/rector/job.rb', line 40
def join
while @backend.workers_working?
sleep 5
end
end
|