Module: ResqueRetry::Server::Helpers

Defined in:
lib/resque-retry/server.rb

Overview

Helper methods used by retry tab.

Instance Method Summary collapse

Instance Method Details

#cancel_retry(job) ⇒ Object

cancels job retry


67
68
69
70
71
72
73
# File 'lib/resque-retry/server.rb', line 67

def cancel_retry(job)
  klass = get_class(job)
  retry_key = retry_key_for_job(job)
  Resque.remove_delayed(klass, *job['args'])
  Resque.redis.del("failure-#{retry_key}")
  Resque.redis.del(retry_key)
end

#local_template(path) ⇒ Object

reads a 'local' template file.


61
62
63
64
# File 'lib/resque-retry/server.rb', line 61

def local_template(path)
  # Is there a better way to specify alternate template locations with sinatra?
  File.read(File.join(File.dirname(__FILE__), "server/views/#{path}"))
end

#retry_attempts_for_job(job) ⇒ Object

gets the number of retry attempts for a job.


51
52
53
# File 'lib/resque-retry/server.rb', line 51

def retry_attempts_for_job(job)
  Resque.redis.get(retry_key_for_job(job))
end

#retry_failure_details(retry_key) ⇒ Object

gets the failure details hash for a job.


56
57
58
# File 'lib/resque-retry/server.rb', line 56

def retry_failure_details(retry_key)
  Resque.decode(Resque.redis.get("failure-#{retry_key}"))
end

#retry_key_for_job(job) ⇒ Object

builds a retry key for the specified job.


41
42
43
44
45
46
47
48
# File 'lib/resque-retry/server.rb', line 41

def retry_key_for_job(job)
  klass = get_class(job)
  if klass.respond_to?(:redis_retry_key)
    klass.redis_retry_key(job['args'])
  else
    nil
  end
end