heroku-resque-workers-scaler 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/config/scaler_config.yml +1 -0
- data/lib/heroku-resque-workers-scaler.rb +6 -1
- data/lib/heroku-resque-workers-scaler/config.rb +4 -0
- data/lib/heroku-resque-workers-scaler/scaler.rb +22 -13
- data/lib/heroku-resque-workers-scaler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80444234023d5416075b0d6d274537223ec8b57b
|
4
|
+
data.tar.gz: f844a65e4d590cd1bdc7485981a97eb1f148b845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0278d725ae5a814419f546978d3633957c51bf8e2547c6e43141338225abaa518ff7933d465073cd71c779988c4c4ee3707041f1b39efd49fb90160be38d180c
|
7
|
+
data.tar.gz: d37a1fb67d184dcdc10c5c38b70163e830715bc73b08a66dd45fd69b0fb0f5677a555bfe22bdd8f5c92b0a1b9f12c9562b0f5d3ca038af2282fa08eea4c1916d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# Changelog VERSION = '0.3.0'
|
2
|
+
* feature
|
3
|
+
* Add another mode for thresholds
|
4
|
+
|
5
|
+
* bug fix
|
6
|
+
* fix size of working job count at ZERO instead of one
|
7
|
+
|
8
|
+
[Fullcahnges](https://github.com/joel/heroku-resque-workers-scaler/pull/8)
|
9
|
+
|
1
10
|
# Changelog VERSION = '0.2.1'
|
2
11
|
|
3
12
|
[Fullcahnges](https://github.com/joel/heroku-resque-workers-scaler/pull/7)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,7 +26,7 @@ You need to defined two vars for your heroku :
|
|
26
26
|
```
|
27
27
|
heroku config:add HEROKU_API_KEY=your_api_key -a your_app_name
|
28
28
|
heroku config:add HEROKU_APP_NAME=your_app_name -a your_app_name
|
29
|
-
heroku config:add
|
29
|
+
heroku config:add SAFE_MODE=true -a your_app_name
|
30
30
|
```
|
31
31
|
|
32
32
|
## Run localy
|
@@ -58,6 +58,7 @@ You can change the thresholds, environments of execution and the name of your wo
|
|
58
58
|
|
59
59
|
Exmple YAML file contents:
|
60
60
|
|
61
|
+
mode: :thresholds # :fit, :half, :third
|
61
62
|
thresholds:
|
62
63
|
- :workers: 1
|
63
64
|
:job_count: 1
|
@@ -67,6 +68,8 @@ Exmple YAML file contents:
|
|
67
68
|
- production
|
68
69
|
worker_name: resque
|
69
70
|
|
71
|
+
if you use `mode: :fit` the number of job is exactly the same of available worker, `:half` the number of worker is 1/2 of number of job in queue, and for `third` 1/3
|
72
|
+
|
70
73
|
I just bundled it into a gem for easy inclusion into other projects.
|
71
74
|
|
72
75
|
#### Usage
|
data/config/scaler_config.yml
CHANGED
@@ -54,7 +54,7 @@ module HerokuResqueAutoScale
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def authorized?
|
57
|
-
|
57
|
+
Config.environments.include? _environment
|
58
58
|
end
|
59
59
|
|
60
60
|
def _environment
|
@@ -66,7 +66,7 @@ module HerokuResqueAutoScale
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def worker_name
|
69
|
-
|
69
|
+
Config.worker_name
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
@@ -81,18 +81,27 @@ module HerokuResqueAutoScale
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def after_enqueue_scale_up(*args)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
#
|
91
|
-
if Scaler.
|
92
|
-
|
84
|
+
case Config.mode
|
85
|
+
when :thresholds
|
86
|
+
Config.thresholds.reverse_each do |scale_info|
|
87
|
+
# Run backwards so it gets set to the highest value first
|
88
|
+
# Otherwise if there were 70 jobs, it would get set to 1, then 2, then 3, etc
|
89
|
+
|
90
|
+
# If we have a job count greater than or equal to the job limit for this scale info
|
91
|
+
if Scaler.job_count >= scale_info[:job_count]
|
92
|
+
# Set the number of workers unless they are already set to a level we want. Don't scale down here!
|
93
|
+
if Scaler.workers <= scale_info[:workers]
|
94
|
+
Scaler.workers = scale_info[:workers]
|
95
|
+
end
|
96
|
+
break # We've set or ensured that the worker count is high enough
|
93
97
|
end
|
94
|
-
break # We've set or ensured that the worker count is high enough
|
95
98
|
end
|
99
|
+
when :fit
|
100
|
+
Scaler.workers = Scaler.job_count
|
101
|
+
when :half
|
102
|
+
Scaler.workers = (Scaler.job_count/2)
|
103
|
+
when :third
|
104
|
+
Scaler.workers = (Scaler.job_count/3)
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
@@ -101,6 +110,6 @@ module HerokuResqueAutoScale
|
|
101
110
|
def scale_down
|
102
111
|
# Nothing fancy, just shut everything down if we have no pending jobs
|
103
112
|
# and one working job (which is this job)
|
104
|
-
Scaler.workers = 0 if Scaler.job_count.zero? && Scaler.working_job_count
|
113
|
+
Scaler.workers = 0 if Scaler.job_count.zero? && Scaler.working_job_count.zero?
|
105
114
|
end
|
106
115
|
end
|