resque-cluster 0.0.6 → 0.0.7
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/Gemfile +1 -1
- data/Gemfile.lock +17 -17
- data/lib/resque/cluster/member.rb +2 -21
- data/lib/resque/cluster/version.rb +1 -1
- data/spec/unit/member_spec.rb +5 -31
- 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: c01c8144464501ef2314afdc09a673a490580f83
|
4
|
+
data.tar.gz: c31b0a48f3474c61f1ae76e9816432d12c93e4db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7689f5f5c61d328fe92f805d2273beb0468a66c6165b696122a99317c4930305f1891fab1487a4b7014b031ba7bc3c76f71036ebe8ea3ad5d7b0657c682b870c
|
7
|
+
data.tar.gz: 7147b14db7ec1f9051b849a9b6bcb2735205c3ee540fe97631cf29056b2351116400f2c21cd24bcded0ff4cd17a699fdc3d2653bdbdb447126b2846748b3363e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,8 +3,8 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
addressable (2.3.8)
|
5
5
|
ast (2.0.0)
|
6
|
-
astrolabe (1.3.
|
7
|
-
parser (
|
6
|
+
astrolabe (1.3.1)
|
7
|
+
parser (~> 2.2)
|
8
8
|
awesome_print (1.6.1)
|
9
9
|
builder (3.2.2)
|
10
10
|
coderay (1.1.0)
|
@@ -23,9 +23,9 @@ GEM
|
|
23
23
|
multi_json (>= 1.7.5, < 2.0)
|
24
24
|
nokogiri (~> 1.6.3)
|
25
25
|
oauth2
|
26
|
-
gru (0.0
|
26
|
+
gru (0.1.0)
|
27
27
|
redis (> 0.0)
|
28
|
-
hashie (3.4.
|
28
|
+
hashie (3.4.2)
|
29
29
|
highline (1.7.2)
|
30
30
|
jeweler (2.0.1)
|
31
31
|
builder
|
@@ -36,13 +36,13 @@ GEM
|
|
36
36
|
nokogiri (>= 1.5.10)
|
37
37
|
rake
|
38
38
|
rdoc
|
39
|
-
json (1.8.
|
40
|
-
jwt (1.5.
|
39
|
+
json (1.8.3)
|
40
|
+
jwt (1.5.1)
|
41
41
|
method_source (0.8.2)
|
42
42
|
mini_portile (0.6.2)
|
43
43
|
mock_redis (0.15.0)
|
44
44
|
mono_logger (1.1.0)
|
45
|
-
multi_json (1.11.
|
45
|
+
multi_json (1.11.2)
|
46
46
|
multi_xml (0.5.5)
|
47
47
|
multipart-post (2.0.0)
|
48
48
|
nokogiri (1.6.6.2)
|
@@ -53,21 +53,21 @@ GEM
|
|
53
53
|
multi_json (~> 1.3)
|
54
54
|
multi_xml (~> 0.5)
|
55
55
|
rack (~> 1.2)
|
56
|
-
parser (2.2.2.
|
56
|
+
parser (2.2.2.6)
|
57
57
|
ast (>= 1.1, < 3.0)
|
58
58
|
powerpack (0.1.1)
|
59
|
-
pry (0.
|
60
|
-
coderay (~> 1.0)
|
61
|
-
method_source (~> 0.8)
|
59
|
+
pry (0.10.1)
|
60
|
+
coderay (~> 1.1.0)
|
61
|
+
method_source (~> 0.8.1)
|
62
62
|
slop (~> 3.4)
|
63
|
-
rack (1.6.
|
63
|
+
rack (1.6.4)
|
64
64
|
rack-protection (1.5.3)
|
65
65
|
rack
|
66
66
|
rainbow (2.0.0)
|
67
67
|
rake (10.4.2)
|
68
68
|
rdoc (3.12.2)
|
69
69
|
json (~> 1.4)
|
70
|
-
redis (3.2.
|
70
|
+
redis (3.2.2)
|
71
71
|
redis-namespace (1.5.2)
|
72
72
|
redis (~> 3.0, >= 3.0.4)
|
73
73
|
resque (1.25.2)
|
@@ -92,9 +92,9 @@ GEM
|
|
92
92
|
rspec-mocks (3.1.3)
|
93
93
|
rspec-support (~> 3.1.0)
|
94
94
|
rspec-support (3.1.2)
|
95
|
-
rubocop (0.
|
95
|
+
rubocop (0.32.1)
|
96
96
|
astrolabe (~> 1.3)
|
97
|
-
parser (>= 2.2.2.
|
97
|
+
parser (>= 2.2.2.5, < 3.0)
|
98
98
|
powerpack (~> 0.1)
|
99
99
|
rainbow (>= 1.99.1, < 3.0)
|
100
100
|
ruby-progressbar (~> 1.4)
|
@@ -108,7 +108,7 @@ GEM
|
|
108
108
|
rack (~> 1.4)
|
109
109
|
rack-protection (~> 1.4)
|
110
110
|
tilt (>= 1.3, < 3)
|
111
|
-
slop (3.
|
111
|
+
slop (3.6.0)
|
112
112
|
thread_safe (0.3.5)
|
113
113
|
tilt (2.0.1)
|
114
114
|
trollop (2.1.2)
|
@@ -121,7 +121,7 @@ PLATFORMS
|
|
121
121
|
DEPENDENCIES
|
122
122
|
awesome_print
|
123
123
|
bundler (~> 1.0)
|
124
|
-
gru (= 0.0
|
124
|
+
gru (= 0.1.0)
|
125
125
|
jeweler (~> 2.0.1)
|
126
126
|
mock_redis (~> 0.15.0)
|
127
127
|
pry
|
@@ -13,21 +13,13 @@ module Resque
|
|
13
13
|
@global_config = parse_config(Cluster.config[:global_config_path])
|
14
14
|
@global_config = @local_config if global_config.empty?
|
15
15
|
@worker_count_manager = initialize_gru
|
16
|
-
|
17
|
-
register
|
18
16
|
end
|
19
17
|
|
20
18
|
def perform
|
21
19
|
check_for_worker_count_adjustment
|
22
|
-
ping
|
23
|
-
end
|
24
|
-
|
25
|
-
def register
|
26
|
-
ping
|
27
20
|
end
|
28
21
|
|
29
22
|
def unregister
|
30
|
-
unping
|
31
23
|
remove_counts
|
32
24
|
unqueue_all_workers
|
33
25
|
end
|
@@ -51,18 +43,6 @@ module Resque
|
|
51
43
|
"#{member_prefix}:running_workers"
|
52
44
|
end
|
53
45
|
|
54
|
-
def ping_namespace
|
55
|
-
global_prefix + ":pings"
|
56
|
-
end
|
57
|
-
|
58
|
-
def ping
|
59
|
-
Resque.redis.hset(ping_namespace, hostname, Time.now.utc)
|
60
|
-
end
|
61
|
-
|
62
|
-
def unping
|
63
|
-
Resque.redis.hdel(ping_namespace, hostname)
|
64
|
-
end
|
65
|
-
|
66
46
|
def initialize_gru
|
67
47
|
Gru.create(cluster_member_settings)
|
68
48
|
end
|
@@ -113,7 +93,8 @@ module Resque
|
|
113
93
|
rebalance_flag: @global_config["rebalance_cluster"] || false,
|
114
94
|
cluster_name: Cluster.config[:cluster_name],
|
115
95
|
environment_name: Cluster.config[:environment],
|
116
|
-
presume_host_dead_after: @global_config["presume_dead_after"] || 120
|
96
|
+
presume_host_dead_after: @global_config["presume_dead_after"] || 120,
|
97
|
+
manage_worker_heartbeats: true
|
117
98
|
}
|
118
99
|
end
|
119
100
|
end
|
data/spec/unit/member_spec.rb
CHANGED
@@ -15,7 +15,7 @@ RSpec.describe Resque::Cluster::Member do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
after :all do
|
18
|
-
Resque::Cluster.member
|
18
|
+
Resque::Cluster.member
|
19
19
|
Resque::Cluster.config = nil
|
20
20
|
Resque::Cluster.member = nil
|
21
21
|
end
|
@@ -29,13 +29,14 @@ RSpec.describe Resque::Cluster::Member do
|
|
29
29
|
:rebalance_flag => false,
|
30
30
|
:presume_host_dead_after => 120,
|
31
31
|
:cluster_name => "unit-test-cluster",
|
32
|
-
:environment_name => "unit-test"
|
32
|
+
:environment_name => "unit-test",
|
33
|
+
:manage_worker_heartbeats => true
|
33
34
|
}
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'returns a correct cluster settings hash' do
|
37
38
|
expect(Resque::Cluster.member.send(:cluster_member_settings)).to eq(@settings_hash)
|
38
|
-
Resque::Cluster.member
|
39
|
+
Resque::Cluster.member
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'returns a correct cluster settings hash with global_config with a rebalance param' do
|
@@ -46,16 +47,6 @@ RSpec.describe Resque::Cluster::Member do
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
context '#register' do
|
50
|
-
before :all do
|
51
|
-
@member.register
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'pings into redis to let the rest of the cluster know of it' do
|
55
|
-
expect(@redis.hget('resque:cluster:unit-test-cluster:unit-test:pings', @@hostname)).to_not be_nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
50
|
context '#check_for_worker_count_adjustment' do
|
60
51
|
before :all do
|
61
52
|
@redis.hset("GRU:unit-test:unit-test-cluster:global:max_workers","bar",2)
|
@@ -75,27 +66,10 @@ RSpec.describe Resque::Cluster::Member do
|
|
75
66
|
end
|
76
67
|
end
|
77
68
|
|
78
|
-
context '#unregister' do
|
79
|
-
before :all do
|
80
|
-
@member.unregister
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'removes everything about itself from redis' do
|
84
|
-
expect(@redis.hget('resque:cluster:unit-test-cluster:unit-test', @@hostname)).to be_nil
|
85
|
-
expect(@redis.get("resque:cluster:unit-test-cluster:unit-test:#{@@hostname}:running_workers")).to be_nil
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'moves all the current running workers into the global queue if rebalance_on_termination is set to true' do
|
89
|
-
expect(@redis.hget('GRU:unit-test:unit-test-cluster:global:workers_running', 'bar')).to eq '0'
|
90
|
-
expect(@redis.hget('GRU:unit-test:unit-test-cluster:global:workers_running', 'foo')).to eq '0'
|
91
|
-
expect(@redis.hget("GRU:unit-test:unit-test-cluster:#{@@hostname}:workers_running", 'bar')).to be_nil
|
92
|
-
expect(@redis.hget("GRU:unit-test:unit-test-cluster:#{@@hostname}:workers_running", 'foo')).to be_nil
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
69
|
after :all do
|
97
70
|
@redis.del("GRU:unit-test:unit-test-cluster:global:max_workers")
|
98
71
|
@redis.del("GRU:unit-test:unit-test-cluster:global:workers_running")
|
72
|
+
@redis.del("GRU:unit-test:unit-test-cluster:heartbeats")
|
99
73
|
end
|
100
74
|
|
101
75
|
end
|