Class: GovernorBackground::Resque::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/governor_background/resque/job.rb

Overview

A wrapper around a Resque job.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, job_id) ⇒ Job

Initializes the job with a job name (passed from GovernorBackground.run) and a unique identifier for the Resque job.



9
10
11
12
13
# File 'lib/governor_background/resque/job.rb', line 9

def initialize(name, job_id)
  @name = name
  @id = job_id
  @created_at = Time.now
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/governor_background/resque/job.rb', line 5

def created_at
  @created_at
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/governor_background/resque/job.rb', line 5

def name
  @name
end

Instance Method Details

#completed?Boolean

Returns true if this job has been completed, false otherwise.

Returns:

  • (Boolean)


34
35
36
# File 'lib/governor_background/resque/job.rb', line 34

def completed?
  proxy :completed?
end

#failed?Boolean

Returns true if this job has failed, false otherwise.

Returns:

  • (Boolean)


39
40
41
# File 'lib/governor_background/resque/job.rb', line 39

def failed?
  proxy :failed?
end

#killed?Boolean

Returns true if this job has been killed, false otherwise.

Returns:

  • (Boolean)


44
45
46
# File 'lib/governor_background/resque/job.rb', line 44

def killed?
  proxy :killed?
end

#messageObject

Returns a human readable message describing the status.



49
50
51
# File 'lib/governor_background/resque/job.rb', line 49

def message
  proxy :message, ''
end

#queued?Boolean

Returns true if this job is currently waiting in the queue, false otherwise.

Returns:

  • (Boolean)


23
24
25
# File 'lib/governor_background/resque/job.rb', line 23

def queued?
  proxy :queued?
end

#statusObject

Returns the status of the job, which can be any of the boolean methods or unknown.



17
18
19
# File 'lib/governor_background/resque/job.rb', line 17

def status
  (job = resque_status) ? job.status : 'unknown'
end

#working?Boolean

Returns true if this job is currently being processed, false otherwise.

Returns:

  • (Boolean)


29
30
31
# File 'lib/governor_background/resque/job.rb', line 29

def working?
  proxy :working?
end