class JobDispatch::Broker::InternalJob

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.

Attributes

id[RW]

Public Class Methods

new(command, queue) click to toggle source
# 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

Public Instance Methods

as_json() click to toggle source
# 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?() click to toggle source
# File lib/job_dispatch/broker/internal_job.rb, line 17
def timed_out?
  Time.now > @timeout_at
end