Class: JobDispatch::Broker::InternalJob
- Inherits:
-
Object
- Object
- JobDispatch::Broker::InternalJob
- Defined in:
- lib/job_dispatch/broker/internal_job.rb
Overview
a class to represent a worker processing a broker command that is not a job. It is still tracked by the broker as if it was a job, though. If the worker does not reply, they will be timed out. And status report will show the worker state as executing this command.
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(command, queue) ⇒ InternalJob
constructor
A new instance of InternalJob.
- #timed_out? ⇒ Boolean
Constructor Details
#initialize(command, queue) ⇒ InternalJob
Returns a new instance of InternalJob.
10 11 12 13 14 15 |
# File 'lib/job_dispatch/broker/internal_job.rb', line 10 def initialize(command, queue) @id = SecureRandom.uuid @command = command @timeout_at = Time.now + JobDispatch::Job::DEFAULT_EXECUTION_TIMEOUT @queue = queue end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
8 9 10 |
# File 'lib/job_dispatch/broker/internal_job.rb', line 8 def command @command end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/job_dispatch/broker/internal_job.rb', line 8 def id @id end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
8 9 10 |
# File 'lib/job_dispatch/broker/internal_job.rb', line 8 def queue @queue end |
Instance Method Details
#as_json ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/job_dispatch/broker/internal_job.rb', line 21 def as_json { command: command, id: id, queue: queue, target: "JobDispatch", method: command } end |
#timed_out? ⇒ Boolean
17 18 19 |
# File 'lib/job_dispatch/broker/internal_job.rb', line 17 def timed_out? Time.now > @timeout_at end |