resque-cluster 0.2.3 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c483198ba655c6b6a01d9e5bf12bc94c78d7b97
4
- data.tar.gz: 2ba5e136b052f24b10e034caa4b6dbb25faafb54
3
+ metadata.gz: fc8ed9831d6ca9e37cffd6b8307a99d46e244c98
4
+ data.tar.gz: 43aa29967bd118a139a252fdab27bc5415b0aa30
5
5
  SHA512:
6
- metadata.gz: e179193ae5214b87436aef62b1af2193153894f6f9e9d39980d3b110d8d364635771c8e925d8db12886432e1790986d6b6bbf1cb515e3a4eac67eed87996e590
7
- data.tar.gz: 9c5502109e773a4869e565f11d5d28bc279bebb8a425de6f6ddd907e3d98c7e96dbfa6693ef2ae97ecce21f3995813268f959934520c007d6684b164b344fbcd
6
+ metadata.gz: bbcdcba1bd2556726b9cda6ecb186be4b5b99bc6b3b5ee0190f1b31692dc9ac83cac5499c7bd1318d2d40356e62b0710245781bd67750c2da9e78826514affa0
7
+ data.tar.gz: 743b31b2c4fe8ecf48525c4f18f71604ea83b275457d7cef1e869e334cdbdb9b656de142a324c60b654d339cd7010ea1530a3f8273760bb4c525d4da170d1265
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GEM
12
12
  ast (2.3.0)
13
13
  awesome_print (1.7.0)
14
14
  builder (3.2.2)
15
- coderay (1.1.1)
15
+ byebug (9.0.5)
16
16
  descendants_tracker (0.0.4)
17
17
  thread_safe (~> 0.3, >= 0.3.1)
18
18
  diff-lcs (1.2.5)
@@ -42,7 +42,6 @@ GEM
42
42
  rdoc
43
43
  json (1.8.3)
44
44
  jwt (1.5.4)
45
- method_source (0.8.2)
46
45
  mini_portile2 (2.1.0)
47
46
  mono_logger (1.1.0)
48
47
  multi_json (1.12.1)
@@ -61,10 +60,6 @@ GEM
61
60
  ast (~> 2.2)
62
61
  pkg-config (1.1.7)
63
62
  powerpack (0.1.1)
64
- pry (0.10.4)
65
- coderay (~> 1.1.0)
66
- method_source (~> 0.8.1)
67
- slop (~> 3.4)
68
63
  rack (1.6.4)
69
64
  rack-protection (1.5.3)
70
65
  rack
@@ -113,7 +108,6 @@ GEM
113
108
  rack (~> 1.5)
114
109
  rack-protection (~> 1.4)
115
110
  tilt (>= 1.3, < 3)
116
- slop (3.6.0)
117
111
  sys-proctable (1.1.1)
118
112
  thread_safe (0.3.5)
119
113
  tilt (2.0.5)
@@ -128,9 +122,9 @@ PLATFORMS
128
122
  DEPENDENCIES
129
123
  awesome_print (> 0.0)
130
124
  bundler (~> 1.7)
125
+ byebug (> 0.0)
131
126
  ffi
132
127
  jeweler (~> 2.0.1)
133
- pry (> 0.0)
134
128
  rdoc (~> 3.12)
135
129
  resque-cluster!
136
130
  rspec (~> 3.1.0)
@@ -38,7 +38,7 @@ module Resque
38
38
  {
39
39
  manage_worker_heartbeats: true,
40
40
  host_maximums: host_maximums,
41
- client_settings: Resque.redis.client.options,
41
+ client_settings: gru_redis_connection,
42
42
  cluster_name: Cluster.config[:cluster_name],
43
43
  environment_name: Cluster.config[:environment],
44
44
  cluster_maximums: cluster_maximums,
@@ -70,6 +70,19 @@ module Resque
70
70
 
71
71
  private
72
72
 
73
+ def gru_redis_connection
74
+ case config_type
75
+ when :separate
76
+ global_config['redis_client_options'] ||
77
+ Resque.redis.client.options
78
+ when :old
79
+ Resque.redis.client.options
80
+ when :new
81
+ config['redis_client_options'] ||
82
+ Resque.redis.client.options
83
+ end
84
+ end
85
+
73
86
  def complete_worker_config?
74
87
  host_keys = Set.new(host_maximums.delete_if { |_, v| v.nil? }.keys)
75
88
  cluster_keys = Set.new(cluster_maximums.delete_if { |_, v| v.nil? }.keys)
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  class Cluster
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'resque-pool', '~> 0.5.0'
22
22
  s.add_dependency 'gru', '0.1.3'
23
23
 
24
- s.add_development_dependency 'pry', '> 0.0'
24
+ s.add_development_dependency 'byebug', '> 0.0'
25
25
  s.add_development_dependency 'awesome_print', '> 0.0'
26
26
  s.add_development_dependency 'rspec', '~> 3.1.0'
27
27
  s.add_development_dependency 'rdoc', '~> 3.12'
@@ -3,3 +3,6 @@ global_maximums:
3
3
  bar: 50
4
4
  "foo,bar,baz": 1
5
5
  rebalance_cluster: true
6
+ redis_client_options:
7
+ host: "127.0.0.1"
8
+ port: 6378
@@ -115,9 +115,9 @@ RSpec.describe "Resque test-cluster" do
115
115
 
116
116
  context "Multiple Clusters and Environments" do
117
117
  before :all do
118
- @a = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG)
119
- @b = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG, "test1-cluster")
120
- @c = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG, "test-cluster", "test1")
118
+ @a = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3)
119
+ @b = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3, "test1-cluster")
120
+ @c = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3, "test-cluster", "test1")
121
121
  @a.start
122
122
  @b.start
123
123
  @c.start
@@ -138,8 +138,8 @@ RSpec.describe "Resque test-cluster" do
138
138
 
139
139
  context "Rebalance after global maximums change" do
140
140
  before :all do
141
- @a = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG)
142
- @b = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG)
141
+ @a = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3)
142
+ @b = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3)
143
143
  @c = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_REBALANCE_CONFIG3)
144
144
  @a.start
145
145
  @b.start
@@ -172,13 +172,19 @@ RSpec.describe "Resque test-cluster" do
172
172
  @b = TestMemberManager.new(LOCAL_CONFIG2, GLOBAL_CONFIG2)
173
173
  @c = TestMemberManager.new(LOCAL_CONFIG2, GLOBAL_REBALANCE_CONFIG2)
174
174
  @a.start
175
+ @a_ping = @a.last_gru_ping
175
176
  @b.start
177
+ @b_ping = @b.last_gru_ping
176
178
  @c.start
179
+ @c_ping = @c.last_gru_ping
177
180
  sleep(5) # rebalance time
178
181
  end
179
182
 
180
183
  it 'expects to have a correct number of workers in the cluster after multiple restarts' do
181
184
  expect(TestMemberManager.counts).to eq({"star"=>12})
185
+ expect(@a.last_gru_ping).to be > @a_ping
186
+ expect(@b.last_gru_ping).to be > @b_ping
187
+ expect(@c.last_gru_ping).to be > @c_ping
182
188
  2.times do
183
189
  sleep(5)
184
190
  @a.stop
@@ -190,11 +196,20 @@ RSpec.describe "Resque test-cluster" do
190
196
  @c.stop
191
197
  @c.start
192
198
  end
199
+ @a_ping = @a.last_gru_ping
200
+ @b_ping = @b.last_gru_ping
201
+ @c_ping = @c.last_gru_ping
193
202
  sleep(8) # rebalance time
194
203
  expect(TestMemberManager.counts).to eq({"star"=>12})
195
204
  expect(@a.counts).to eq({"star"=>4})
196
205
  expect(@b.counts).to eq({"star"=>4})
197
206
  expect(@c.counts).to eq({"star"=>4})
207
+ expect(@a.last_gru_ping).to be > @a_ping
208
+ expect(@b.last_gru_ping).to be > @b_ping
209
+ expect(@c.last_gru_ping).to be > @c_ping
210
+ @a_ping = @a.last_gru_ping
211
+ @b_ping = @b.last_gru_ping
212
+ @c_ping = @c.last_gru_ping
198
213
  end
199
214
 
200
215
  it 'will not rebalance after the cluster is switched to rebalance-cluster false' do
@@ -202,6 +217,9 @@ RSpec.describe "Resque test-cluster" do
202
217
  sleep(2)
203
218
  @b.start
204
219
  sleep(8)
220
+ expect(@a.last_gru_ping).to be > @a_ping
221
+ expect(@b.last_gru_ping).to be > @b_ping
222
+ expect(@c.last_gru_ping).to be > @c_ping
205
223
  expect(TestMemberManager.counts).to eq({"star"=>12})
206
224
  expect(@a.counts).to eq({"star"=>6})
207
225
  expect(@b.counts).to eq({})
@@ -3,3 +3,6 @@ global_maximums:
3
3
  tar: 8
4
4
  "par,tar,var": 1
5
5
  presume_dead_after: 10
6
+ redis_client_options:
7
+ host: "127.0.0.1"
8
+ port: 6378
@@ -3,3 +3,6 @@ global_maximums:
3
3
  par: 4
4
4
  tar: 6
5
5
  "par,tar,var": 2
6
+ redis_client_options:
7
+ host: "127.0.0.1"
8
+ port: 6378
@@ -1,4 +1,4 @@
1
- require 'pry'
1
+ require 'byebug'
2
2
  require 'rspec'
3
3
  require 'sys/proctable'
4
4
  require 'resque'
@@ -1,5 +1,6 @@
1
1
  class TestMemberManager
2
2
  include Sys
3
+ require 'resque/cluster/config'
3
4
 
4
5
  attr_accessor :pid
5
6
 
@@ -90,6 +91,14 @@ class TestMemberManager
90
91
  @hostname ||= "#{Socket.gethostname}-#{member_count+1}"
91
92
  end
92
93
 
94
+ def last_gru_ping
95
+ redis_connection.hget("GRU:#{@environment}:#{@cluster_name}:heartbeats", hostname).to_i
96
+ end
97
+
98
+ def redis_connection
99
+ @redis_connection ||= Redis.new
100
+ end
101
+
93
102
  def self.parse_worker_name(worker_cmdline)
94
103
  worker_cmdline.gsub(/resque(\d|\.|-)*:\sWaiting\sfor\s/, '')
95
104
  end
@@ -131,6 +131,34 @@ RSpec.describe Resque::Cluster::Config do
131
131
  end
132
132
  end
133
133
 
134
+ context "with separate redis config in config files" do
135
+ let(:config) { Resque::Cluster::Config.new(local_config_path, global_config_path) }
136
+ let(:local_config_path) { File.expand_path(File.dirname(__FILE__) + '/../local_config.yml') }
137
+ let(:global_config_path) { File.expand_path(File.dirname(__FILE__) + '/../global_rebalance_config.yml') }
138
+
139
+ let(:correct_hash) do
140
+ {
141
+ cluster_maximums: { 'foo' => 2, 'bar' => 50, "foo,bar,baz" => 1 },
142
+ host_maximums: { 'foo' => 1, 'bar' => 9, "foo,bar,baz" => 1 },
143
+ client_settings: {"host"=>"127.0.0.1", "port"=>6378},
144
+ rebalance_flag: true,
145
+ presume_host_dead_after: 120,
146
+ max_workers_per_host: nil,
147
+ cluster_name: "unit-test-cluster",
148
+ environment_name: "unit-test",
149
+ manage_worker_heartbeats: true
150
+ }
151
+ end
152
+
153
+ it_behaves_like 'a valid config'
154
+
155
+ it "config should have no warnings or errors" do
156
+ expect(config.errors.count).to eql(0)
157
+ expect(config.warnings.count).to eql(0)
158
+ end
159
+ end
160
+
161
+
134
162
  context 'with a missing local maximum' do
135
163
  let(:config) { Resque::Cluster::Config.new(local_config_path, global_config_path) }
136
164
  let(:local_config_path) { support_dir + 'separate_missing_local.yml' }
@@ -1,5 +1,5 @@
1
1
  gem 'resque-pool'
2
- require 'pry'
2
+ require 'byebug'
3
3
  require 'resque/pool/cli'
4
4
  require 'rspec'
5
5
  require 'socket'
@@ -0,0 +1,16 @@
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
14
+ redis_client_options:
15
+ host: "127.0.0.1"
16
+ port: 6378
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.2.3
4
+ version: 0.2.4
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
@@ -39,143 +39,143 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: byebug
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: sys-proctable
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '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'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: ffi
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  description: A management tool for resque workers. Allows spinning up and managing
@@ -186,10 +186,10 @@ executables:
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
- - .document
190
- - .gitignore
191
- - .rspec
192
- - .rubocop.yml
189
+ - ".document"
190
+ - ".gitignore"
191
+ - ".rspec"
192
+ - ".rubocop.yml"
193
193
  - Gemfile
194
194
  - Gemfile.lock
195
195
  - LICENSE.txt
@@ -240,6 +240,7 @@ files:
240
240
  - spec/unit/support/single_old_missing_local.yml
241
241
  - spec/unit/support/valid_config.yml
242
242
  - spec/unit/support/valid_global_config.yml
243
+ - spec/unit/support/valid_global_separate_redis_config.yml
243
244
  - spec/unit/support/valid_local_config.yml
244
245
  - spec/unit/support/valid_single_new_config.yml
245
246
  - spec/unit/support/valid_single_old_config.yml
@@ -253,17 +254,17 @@ require_paths:
253
254
  - lib
254
255
  required_ruby_version: !ruby/object:Gem::Requirement
255
256
  requirements:
256
- - - '>='
257
+ - - ">="
257
258
  - !ruby/object:Gem::Version
258
259
  version: '0'
259
260
  required_rubygems_version: !ruby/object:Gem::Requirement
260
261
  requirements:
261
- - - '>='
262
+ - - ">="
262
263
  - !ruby/object:Gem::Version
263
264
  version: '0'
264
265
  requirements: []
265
266
  rubyforge_project:
266
- rubygems_version: 2.2.2
267
+ rubygems_version: 2.4.8
267
268
  signing_key:
268
269
  specification_version: 4
269
270
  summary: Creates and manages resque worker in a distributed cluster
@@ -303,6 +304,7 @@ test_files:
303
304
  - spec/unit/support/single_old_missing_local.yml
304
305
  - spec/unit/support/valid_config.yml
305
306
  - spec/unit/support/valid_global_config.yml
307
+ - spec/unit/support/valid_global_separate_redis_config.yml
306
308
  - spec/unit/support/valid_local_config.yml
307
309
  - spec/unit/support/valid_single_new_config.yml
308
310
  - spec/unit/support/valid_single_old_config.yml