Class: Resque::Plugins::JobHistory::HistoryDetails
- Inherits:
-
Object
- Object
- Resque::Plugins::JobHistory::HistoryDetails
show all
- Defined in:
- lib/resque/plugins/job_history/history_details.rb
Overview
A base class for job history classes which provides a base key and a few common functions.
Constant Summary
collapse
- NAME_SPACE =
"Resque::Plugins::ResqueJobHistory"
- MAX_LINEAR_HISTORY =
500
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of HistoryDetails.
50
51
52
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 50
def initialize(class_name)
@class_name = class_name
end
|
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
8
9
10
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 8
def class_name
@class_name
end
|
Class Method Details
.class_list_page_size ⇒ Object
23
24
25
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 23
def class_list_page_size
@class_list_page_size ||= Resque::Plugins::JobHistory::PAGE_SIZE
end
|
.class_list_page_size=(value) ⇒ Object
18
19
20
21
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 18
def class_list_page_size=(value)
@class_list_page_size = value
@class_list_page_size = 1 if @class_list_page_size < 1
end
|
.job_history_key ⇒ Object
14
15
16
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 14
def job_history_key
"job_history"
end
|
.linear_page_size ⇒ Object
32
33
34
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 32
def linear_page_size
@linear_page_size ||= Resque::Plugins::JobHistory::PAGE_SIZE
end
|
.linear_page_size=(value) ⇒ Object
27
28
29
30
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 27
def linear_page_size=(value)
@linear_page_size = value
@linear_page_size = 1 if @linear_page_size < 1
end
|
.max_linear_jobs ⇒ Object
36
37
38
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 36
def max_linear_jobs
@max_linear_jobs ||= MAX_LINEAR_HISTORY
end
|
.max_linear_jobs=(value) ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 40
def max_linear_jobs=(value)
@max_linear_jobs = value
return unless @max_linear_jobs.present?
@max_linear_jobs = @max_linear_jobs.to_i
@max_linear_jobs = nil if @max_linear_jobs.negative?
end
|
Instance Method Details
#class_name_valid? ⇒ Boolean
98
99
100
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 98
def class_name_valid?
described_class.present?
end
|
#clean_old_running_jobs ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 106
def clean_old_running_jobs
too_old_time = class_purge_age.ago
running_jobs.jobs.each do |job|
job_start = job.start_time
if job_start.present? && job_start.to_time < too_old_time
job.cancel " Job timed out."
end
end
end
|
#finished_jobs ⇒ Object
66
67
68
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 66
def finished_jobs
@finished_list ||= HistoryList.new(class_name, "finished")
end
|
#job_history_base_key ⇒ Object
#last_run ⇒ Object
102
103
104
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 102
def last_run
running_jobs.latest_job || finished_jobs.latest_job
end
|
#max_concurrent_jobs ⇒ Object
74
75
76
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 74
def max_concurrent_jobs
redis.get(max_running_key).to_i
end
|
#num_finished_jobs ⇒ Object
86
87
88
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 86
def num_finished_jobs
finished_jobs.num_jobs
end
|
#num_running_jobs ⇒ Object
82
83
84
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 82
def num_running_jobs
running_jobs.num_jobs
end
|
#page_size ⇒ Object
118
119
120
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 118
def page_size
class_page_size
end
|
#redis ⇒ Object
54
55
56
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 54
def redis
@redis ||= Redis::Namespace.new(NAME_SPACE, redis: Resque.redis)
end
|
#running_jobs ⇒ Object
62
63
64
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 62
def running_jobs
@running_list ||= HistoryList.new(class_name, "running")
end
|
#total_failed_jobs ⇒ Object
78
79
80
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 78
def total_failed_jobs
redis.get(total_failed_key).to_i
end
|
#total_finished_jobs ⇒ Object
94
95
96
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 94
def total_finished_jobs
finished_jobs.total
end
|
#total_run_jobs ⇒ Object
90
91
92
|
# File 'lib/resque/plugins/job_history/history_details.rb', line 90
def total_run_jobs
running_jobs.total
end
|