rcarvalho-workless 1.0.2.12 → 1.0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/workless/scalers/base.rb +13 -14
- metadata +2 -2
@@ -6,7 +6,7 @@ module Delayed
|
|
6
6
|
|
7
7
|
class Base
|
8
8
|
def self.jobs
|
9
|
-
Delayed::Job.
|
9
|
+
Delayed::Job.where(:failed_at => nil)
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.scale_info= info
|
@@ -22,19 +22,18 @@ module Delayed
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.calculate_num_workers
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
25
|
+
num_jobs = self.jobs.count
|
26
|
+
@@scale_info ||= {
|
27
|
+
0 => 0,
|
28
|
+
100 => 1,
|
29
|
+
500 => 2,
|
30
|
+
1000 => 3
|
31
|
+
}
|
32
|
+
scale_key = @@scale_info.keys.reverse.select{|v| v <= num_jobs }.first
|
33
|
+
if scale_key.nil?
|
34
|
+
return 0
|
35
|
+
else
|
36
|
+
return @@scale_info[scale_key]
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|