resque-cluster 0.1.1.1 → 0.2.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.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +47 -44
  4. data/lib/resque/cluster.rb +1 -0
  5. data/lib/resque/cluster/config.rb +169 -0
  6. data/lib/resque/cluster/config/file.rb +40 -0
  7. data/lib/resque/cluster/config/verifier.rb +27 -0
  8. data/lib/resque/cluster/member.rb +17 -27
  9. data/lib/resque/cluster/version.rb +1 -1
  10. data/lib/resque/pool/patches.rb +5 -0
  11. data/resque-cluster.gemspec +1 -1
  12. data/spec/integration/cluster_spec.rb +41 -11
  13. data/spec/integration/config/bad_global_config.yml +3 -0
  14. data/spec/integration/config/global_rebalance_config3.yml +5 -0
  15. data/spec/integration/config/rebalance_config.yml +4 -0
  16. data/spec/integration/spec_helper.rb +3 -0
  17. data/spec/integration/test_member_manager.rb +50 -19
  18. data/spec/unit/config/verifier_spec.rb +86 -0
  19. data/spec/unit/config_spec.rb +194 -0
  20. data/spec/unit/member_spec.rb +5 -32
  21. data/spec/unit/resque_pool_patches_spec.rb +3 -3
  22. data/spec/unit/spec_helper.rb +5 -1
  23. data/spec/unit/support/broken_yaml_config.yml +1 -0
  24. data/spec/unit/support/empty_config.yml +1 -0
  25. data/spec/unit/support/missing_global_maximum.yml +3 -0
  26. data/spec/unit/support/missing_local_maximum.yml +3 -0
  27. data/spec/unit/support/non_hash_config.yml +0 -0
  28. data/spec/unit/support/separate_missing_global.yml +2 -0
  29. data/spec/unit/support/separate_missing_local.yml +2 -0
  30. data/spec/unit/support/single_old_missing_global.yml +9 -0
  31. data/spec/unit/support/single_old_missing_local.yml +9 -0
  32. data/spec/unit/support/valid_config.yml +13 -0
  33. data/spec/unit/support/valid_global_config.yml +1 -0
  34. data/spec/unit/support/valid_local_config.yml +1 -0
  35. data/spec/unit/support/valid_single_new_config.yml +13 -0
  36. data/spec/unit/support/valid_single_old_config.yml +10 -0
  37. metadata +72 -30
@@ -20,47 +20,19 @@ RSpec.describe Resque::Cluster::Member do
20
20
  Resque::Cluster.member = nil
21
21
  end
22
22
 
23
- context '#cluster_member_settings' do
24
- before :all do
25
- @settings_hash = {
26
- :cluster_maximums => {'foo' => 2, 'bar' => 50, "foo,bar,baz" => 1},
27
- :host_maximums => {'foo' => 1, 'bar' => 9, "foo,bar,baz" => 1},
28
- :client_settings => @redis.client.options,
29
- :rebalance_flag => false,
30
- :presume_host_dead_after => 120,
31
- :max_workers_per_host => nil,
32
- :cluster_name => "unit-test-cluster",
33
- :environment_name => "unit-test",
34
- :manage_worker_heartbeats => true
35
- }
36
- end
37
-
38
- it 'returns a correct cluster settings hash' do
39
- expect(Resque::Cluster.member.send(:cluster_member_settings)).to eq(@settings_hash)
40
- Resque::Cluster.member
41
- end
42
-
43
- it 'returns a correct cluster settings hash with global_config with a rebalance param' do
44
- Resque::Cluster.config[:global_config_path] = File.expand_path(File.dirname(__FILE__) + '/../global_rebalance_config.yml')
45
- @settings_hash[:rebalance_flag] = true
46
- @member = Resque::Cluster.init(@pool)
47
- expect(Resque::Cluster.member.send(:cluster_member_settings)).to eq(@settings_hash)
48
- end
49
- end
50
-
51
23
  context '#check_for_worker_count_adjustment' do
52
24
  before :all do
53
25
  @redis.hset("GRU:unit-test:unit-test-cluster:global:max_workers","bar",2)
54
- @redis.hset("GRU:unit-test:unit-test-cluster:#{@@hostname}:max_workers","bar",2)
26
+ @redis.hset("GRU:unit-test:unit-test-cluster:#{HOSTNAME}:max_workers","bar",2)
55
27
  @redis.hset("GRU:unit-test:unit-test-cluster:global:workers_running","bar",0)
56
- @redis.hset("GRU:unit-test:unit-test-cluster:#{@@hostname}:workers_running","bar",0)
28
+ @redis.hset("GRU:unit-test:unit-test-cluster:#{HOSTNAME}:workers_running","bar",0)
57
29
  end
58
30
 
59
31
  it 'adjust worker counts if an adjustment exists on the local command queue' do
60
32
  2.times do
61
33
  @member.check_for_worker_count_adjustment
62
- expect(@redis.hget("GRU:unit-test:unit-test-cluster:#{@@hostname}:workers_running", 'foo')).to eq '1'
63
- expect(@redis.hget("GRU:unit-test:unit-test-cluster:#{@@hostname}:workers_running", 'bar')).to eq '2'
34
+ expect(@redis.hget("GRU:unit-test:unit-test-cluster:#{HOSTNAME}:workers_running", 'foo')).to eq '1'
35
+ expect(@redis.hget("GRU:unit-test:unit-test-cluster:#{HOSTNAME}:workers_running", 'bar')).to eq '2'
64
36
  expect(@member.pool.config['foo']).to eq(1)
65
37
  expect(@member.pool.config['bar']).to eq(2)
66
38
  end
@@ -68,6 +40,7 @@ RSpec.describe Resque::Cluster::Member do
68
40
  end
69
41
 
70
42
  after :all do
43
+ @member.unregister
71
44
  @redis.del("GRU:unit-test:unit-test-cluster:global:max_workers")
72
45
  @redis.del("GRU:unit-test:unit-test-cluster:global:workers_running")
73
46
  @redis.del("GRU:unit-test:unit-test-cluster:heartbeats")
@@ -59,9 +59,9 @@ RSpec.describe Resque::Pool do
59
59
 
60
60
  after :all do
61
61
  @redis = Redis.new
62
- @redis.del("resque:cluster:unit-test-cluster:unit-test:#{@@hostname}:running_workers")
63
- @redis.del("GRU:unit-test:unit-test-cluster:#{@@hostname}:max_workers")
64
- @redis.del("GRU:unit-test:unit-test-cluster:#{@@hostname}:workers_running")
62
+ @redis.del("resque:cluster:unit-test-cluster:unit-test:#{HOSTNAME}:running_workers")
63
+ @redis.del("GRU:unit-test:unit-test-cluster:#{HOSTNAME}:max_workers")
64
+ @redis.del("GRU:unit-test:unit-test-cluster:#{HOSTNAME}:workers_running")
65
65
  @redis.del("GRU:unit-test:unit-test-cluster:global:max_workers")
66
66
  @redis.del("GRU:unit-test:unit-test-cluster:global:workers_running")
67
67
  @redis.del("resque:cluster:unit-test-cluster:unit-test")
@@ -10,4 +10,8 @@ $LOAD_PATH << File.expand_path('lib/resque/pool/*', File.dirname(__FILE__))
10
10
  require 'resque/cluster'
11
11
  require 'resque/pool/patches'
12
12
 
13
- @@hostname = Socket.gethostname
13
+ HOSTNAME = Socket.gethostname
14
+
15
+ def support_dir
16
+ @support_dir ||= Pathname.new(File.dirname(__FILE__)) + 'support'
17
+ end
@@ -0,0 +1 @@
1
+ > 2
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,3 @@
1
+ workers:
2
+ foo:
3
+ local: 1
@@ -0,0 +1,3 @@
1
+ workers:
2
+ foo:
3
+ global: 1
File without changes
@@ -0,0 +1,2 @@
1
+ bar: 50
2
+ "foo,bar,baz": 1
@@ -0,0 +1,2 @@
1
+ bar: 9
2
+ "foo,bar,baz": 1
@@ -0,0 +1,9 @@
1
+ foo: 1
2
+ bar: 9
3
+ "foo,bar,baz": 1
4
+ rebalance_cluster: true
5
+ max_workers_per_host: 10
6
+ presume_dead_after: 60
7
+ global_maximums:
8
+ bar: 50
9
+ "foo,bar,baz": 1
@@ -0,0 +1,9 @@
1
+ bar: 9
2
+ "foo,bar,baz": 1
3
+ rebalance_cluster: true
4
+ max_workers_per_host: 10
5
+ presume_dead_after: 60
6
+ global_maximums:
7
+ foo: 2
8
+ bar: 50
9
+ "foo,bar,baz": 1
@@ -0,0 +1,13 @@
1
+ rebalance_cluster: true
2
+ max_workers_per_host: 10
3
+ presume_dead_after: 60
4
+ workers:
5
+ foo:
6
+ local: 1
7
+ global: 2
8
+ bar:
9
+ local: 9
10
+ global: 50
11
+ "foo,bar,baz":
12
+ local: 1
13
+ global: 1
@@ -0,0 +1 @@
1
+ foo: bar
@@ -0,0 +1 @@
1
+ foo: bar
@@ -0,0 +1,13 @@
1
+ rebalance_cluster: true
2
+ max_workers_per_host: 10
3
+ presume_dead_after: 60
4
+ workers:
5
+ foo:
6
+ local: 1
7
+ global: 2
8
+ bar:
9
+ local: 9
10
+ global: 50
11
+ "foo,bar,baz":
12
+ local: 1
13
+ global: 1
@@ -0,0 +1,10 @@
1
+ foo: 1
2
+ bar: 9
3
+ "foo,bar,baz": 1
4
+ rebalance_cluster: true
5
+ max_workers_per_host: 10
6
+ presume_dead_after: 60
7
+ global_maximums:
8
+ foo: 2
9
+ bar: 50
10
+ "foo,bar,baz": 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasha Portnoy
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: resque-pool
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
@@ -30,138 +30,138 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.1
33
+ version: 0.1.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.1
40
+ version: 0.1.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">"
45
+ - - '>'
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">"
52
+ - - '>'
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: awesome_print
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">"
59
+ - - '>'
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">"
66
+ - - '>'
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 3.1.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rdoc
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.12'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.12'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.7'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.7'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: jeweler
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: 2.0.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: 2.0.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0.31'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.31'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mock_redis
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - "~>"
157
+ - - ~>
158
158
  - !ruby/object:Gem::Version
159
159
  version: 0.15.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - "~>"
164
+ - - ~>
165
165
  - !ruby/object:Gem::Version
166
166
  version: 0.15.0
167
167
  description: A management tool for resque workers. Allows spinning up and managing
@@ -172,10 +172,10 @@ executables:
172
172
  extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
- - ".document"
176
- - ".gitignore"
177
- - ".rspec"
178
- - ".rubocop.yml"
175
+ - .document
176
+ - .gitignore
177
+ - .rspec
178
+ - .rubocop.yml
179
179
  - Gemfile
180
180
  - Gemfile.lock
181
181
  - LICENSE.txt
@@ -183,6 +183,9 @@ files:
183
183
  - Rakefile
184
184
  - bin/resque-cluster_member
185
185
  - lib/resque/cluster.rb
186
+ - lib/resque/cluster/config.rb
187
+ - lib/resque/cluster/config/file.rb
188
+ - lib/resque/cluster/config/verifier.rb
186
189
  - lib/resque/cluster/member.rb
187
190
  - lib/resque/cluster/version.rb
188
191
  - lib/resque/pool/cli_patches.rb
@@ -192,21 +195,40 @@ files:
192
195
  - spec/global_rebalance_config.yml
193
196
  - spec/integration/bin/resque-cluster_member_test
194
197
  - spec/integration/cluster_spec.rb
198
+ - spec/integration/config/bad_global_config.yml
195
199
  - spec/integration/config/global_config.yml
196
200
  - spec/integration/config/global_config2.yml
197
201
  - spec/integration/config/global_config3.yml
198
202
  - spec/integration/config/global_config4.yml
199
203
  - spec/integration/config/global_rebalance_config2.yml
204
+ - spec/integration/config/global_rebalance_config3.yml
200
205
  - spec/integration/config/local_config.yml
201
206
  - spec/integration/config/local_config2.yml
207
+ - spec/integration/config/rebalance_config.yml
202
208
  - spec/integration/spec_helper.rb
203
209
  - spec/integration/standalone_spec.rb
204
210
  - spec/integration/test_member_manager.rb
205
211
  - spec/local_config.yml
212
+ - spec/unit/config/verifier_spec.rb
213
+ - spec/unit/config_spec.rb
206
214
  - spec/unit/member_spec.rb
207
215
  - spec/unit/resque_pool_cli_patches_spec.rb
208
216
  - spec/unit/resque_pool_patches_spec.rb
209
217
  - spec/unit/spec_helper.rb
218
+ - spec/unit/support/broken_yaml_config.yml
219
+ - spec/unit/support/empty_config.yml
220
+ - spec/unit/support/missing_global_maximum.yml
221
+ - spec/unit/support/missing_local_maximum.yml
222
+ - spec/unit/support/non_hash_config.yml
223
+ - spec/unit/support/separate_missing_global.yml
224
+ - spec/unit/support/separate_missing_local.yml
225
+ - spec/unit/support/single_old_missing_global.yml
226
+ - spec/unit/support/single_old_missing_local.yml
227
+ - spec/unit/support/valid_config.yml
228
+ - spec/unit/support/valid_global_config.yml
229
+ - spec/unit/support/valid_local_config.yml
230
+ - spec/unit/support/valid_single_new_config.yml
231
+ - spec/unit/support/valid_single_old_config.yml
210
232
  homepage: https://github.com/yportnoy/resque-cluster
211
233
  licenses:
212
234
  - MIT
@@ -217,17 +239,17 @@ require_paths:
217
239
  - lib
218
240
  required_ruby_version: !ruby/object:Gem::Requirement
219
241
  requirements:
220
- - - ">="
242
+ - - '>='
221
243
  - !ruby/object:Gem::Version
222
244
  version: '0'
223
245
  required_rubygems_version: !ruby/object:Gem::Requirement
224
246
  requirements:
225
- - - ">="
247
+ - - '>='
226
248
  - !ruby/object:Gem::Version
227
249
  version: '0'
228
250
  requirements: []
229
251
  rubyforge_project:
230
- rubygems_version: 2.7.9
252
+ rubygems_version: 2.2.2
231
253
  signing_key:
232
254
  specification_version: 4
233
255
  summary: Creates and manages resque worker in a distributed cluster
@@ -236,18 +258,38 @@ test_files:
236
258
  - spec/global_rebalance_config.yml
237
259
  - spec/integration/bin/resque-cluster_member_test
238
260
  - spec/integration/cluster_spec.rb
261
+ - spec/integration/config/bad_global_config.yml
239
262
  - spec/integration/config/global_config.yml
240
263
  - spec/integration/config/global_config2.yml
241
264
  - spec/integration/config/global_config3.yml
242
265
  - spec/integration/config/global_config4.yml
243
266
  - spec/integration/config/global_rebalance_config2.yml
267
+ - spec/integration/config/global_rebalance_config3.yml
244
268
  - spec/integration/config/local_config.yml
245
269
  - spec/integration/config/local_config2.yml
270
+ - spec/integration/config/rebalance_config.yml
246
271
  - spec/integration/spec_helper.rb
247
272
  - spec/integration/standalone_spec.rb
248
273
  - spec/integration/test_member_manager.rb
249
274
  - spec/local_config.yml
275
+ - spec/unit/config/verifier_spec.rb
276
+ - spec/unit/config_spec.rb
250
277
  - spec/unit/member_spec.rb
251
278
  - spec/unit/resque_pool_cli_patches_spec.rb
252
279
  - spec/unit/resque_pool_patches_spec.rb
253
280
  - spec/unit/spec_helper.rb
281
+ - spec/unit/support/broken_yaml_config.yml
282
+ - spec/unit/support/empty_config.yml
283
+ - spec/unit/support/missing_global_maximum.yml
284
+ - spec/unit/support/missing_local_maximum.yml
285
+ - spec/unit/support/non_hash_config.yml
286
+ - spec/unit/support/separate_missing_global.yml
287
+ - spec/unit/support/separate_missing_local.yml
288
+ - spec/unit/support/single_old_missing_global.yml
289
+ - spec/unit/support/single_old_missing_local.yml
290
+ - spec/unit/support/valid_config.yml
291
+ - spec/unit/support/valid_global_config.yml
292
+ - spec/unit/support/valid_local_config.yml
293
+ - spec/unit/support/valid_single_new_config.yml
294
+ - spec/unit/support/valid_single_old_config.yml
295
+ has_rdoc: