breeder 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/breeder/watcher/beanstalk.rb +7 -2
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -2,15 +2,16 @@ module Breeder
|
|
2
2
|
module Watcher
|
3
3
|
class Beanstalk < Base
|
4
4
|
|
5
|
-
def initialize(client, tube, max_workers)
|
5
|
+
def initialize(client, tube, max_workers, progress_rate = 0.05)
|
6
6
|
raise "max_workers must be at least 1" if max_workers < 1
|
7
7
|
@client, @tube, @max_workers = client, tube, max_workers
|
8
8
|
@last_check = nil
|
9
|
+
@progress_rate = progress_rate
|
9
10
|
end
|
10
11
|
|
11
12
|
def check(num_workers)
|
12
13
|
num = jobs_ready
|
13
|
-
if !!@last_check && num
|
14
|
+
if !!@last_check && insufficient_progress?(num) && num_workers <= @max_workers
|
14
15
|
decision = :spawn
|
15
16
|
elsif !!@last_check && num < 0.5 * @last_check
|
16
17
|
decision = :reap
|
@@ -21,6 +22,10 @@ module Breeder
|
|
21
22
|
decision
|
22
23
|
end
|
23
24
|
|
25
|
+
def insufficient_progress?(num_jobs)
|
26
|
+
num_jobs > (1 - @progress_rate) * @last_check
|
27
|
+
end
|
28
|
+
|
24
29
|
def jobs_ready
|
25
30
|
@client.stats_tube(@tube)['current-jobs-ready']
|
26
31
|
end
|