Class: JobDispatch::Broker::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/job_dispatch/broker/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worker_id = nil, parameters = nil) ⇒ Command

Returns a new instance of Command.



14
15
16
# File 'lib/job_dispatch/broker/command.rb', line 14

def initialize(worker_id=nil, parameters=nil)
  @worker_id, @parameters = worker_id, parameters
end

Instance Attribute Details

#parametersObject

Returns the value of attribute parameters.



12
13
14
# File 'lib/job_dispatch/broker/command.rb', line 12

def parameters
  @parameters
end

#worker_idObject

Returns the value of attribute worker_id.



11
12
13
# File 'lib/job_dispatch/broker/command.rb', line 11

def worker_id
  @worker_id
end

Instance Method Details

#commandObject



26
27
28
# File 'lib/job_dispatch/broker/command.rb', line 26

def command
  @parameters[:command]
end

#queueObject



22
23
24
# File 'lib/job_dispatch/broker/command.rb', line 22

def queue
  (@parameters[:queue] || :default).to_sym
end

#statusObject



30
31
32
# File 'lib/job_dispatch/broker/command.rb', line 30

def status
  @parameters[:status] && @parameters[:status].to_sym
end

#success?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/job_dispatch/broker/command.rb', line 34

def success?
  status == :success
end

#worker_nameObject

the name of the worker



39
40
41
# File 'lib/job_dispatch/broker/command.rb', line 39

def worker_name
  @parameters[:worker_name]
end

#worker_ready?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/job_dispatch/broker/command.rb', line 18

def worker_ready?
  @parameters[:command] == "ready" || @parameters[:ready]
end