gru 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gru/adapters/redis_adapter.rb +19 -6
- data/lib/gru/version.rb +1 -1
- data/spec/gru/adapters/redis_adapter_spec.rb +4 -1
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13495796cf42eb14f84201efe3ff4701a3a4b2e5
|
4
|
+
data.tar.gz: d965fb4d6e6003907e3b4253a6741c0d93549b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa6fec2b08740761f6a436ad5fba23586cd4ead30a3c7f45814b66180e2cfc4de738a834c2a1eab51b5710fa79c701b146937448c759f8f5a7ee871fccfa9e9
|
7
|
+
data.tar.gz: b369f35ebec7200cfae1ff6b02fb7f079a05f440648b575245bf8eb6f7a0982a06668b44872c466c0d5d5312d8976547234a7869a0ccb4685ce4b184044b2f96
|
@@ -123,12 +123,16 @@ module Gru
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def remove_dead_host_workers_from_counts(hostname)
|
126
|
-
|
127
|
-
|
128
|
-
send_message(:
|
129
|
-
|
126
|
+
lock_key = "#{gru_key}:#{hostname}"
|
127
|
+
if send_message(:setnx,lock_key,Time.now.to_i)
|
128
|
+
workers_running_on_dead_host = send_message(:hgetall, "#{gru_key}:#{hostname}:workers_running")
|
129
|
+
workers_running_on_dead_host.each_pair do |worker_name, count|
|
130
|
+
send_message(:hincrby,"#{gru_key}:#{hostname}:workers_running",worker_name,Integer(count)*-1)
|
131
|
+
send_message(:hincrby,global_workers_running_key,worker_name,Integer(count)*-1)
|
132
|
+
end
|
133
|
+
send_message(:del,lock_key)
|
134
|
+
send_message(:hdel,resque_cluster_pings_key,hostname)
|
130
135
|
end
|
131
|
-
send_message(:hdel,resque_cluster_pings_key,hostname)
|
132
136
|
end
|
133
137
|
|
134
138
|
def reset_removed_global_worker_counts(workers)
|
@@ -198,12 +202,17 @@ module Gru
|
|
198
202
|
end
|
199
203
|
|
200
204
|
def worker_counts(worker)
|
201
|
-
@client.multi do |multi|
|
205
|
+
counts = @client.multi do |multi|
|
202
206
|
multi.hget(host_workers_running_key,worker)
|
203
207
|
multi.hget(global_workers_running_key,worker)
|
204
208
|
multi.hget(host_max_worker_key,worker)
|
205
209
|
multi.hget(global_max_worker_key,worker)
|
206
210
|
end
|
211
|
+
if counts[1].to_i <0
|
212
|
+
make_global_workers_count_non_negative(worker)
|
213
|
+
counts[1] = send_message(:hget, global_workers_running_key, worker)
|
214
|
+
end
|
215
|
+
counts
|
207
216
|
end
|
208
217
|
|
209
218
|
def presumed_dead_cluster_members
|
@@ -228,6 +237,10 @@ module Gru
|
|
228
237
|
send_message(:get,"#{gru_key}:rebalance") == "true"
|
229
238
|
end
|
230
239
|
|
240
|
+
def make_global_workers_count_non_negative(worker)
|
241
|
+
send_message(:hset, global_workers_running_key, worker, 0)
|
242
|
+
end
|
243
|
+
|
231
244
|
def presume_host_dead_after
|
232
245
|
dead_after_number_of_seconds = send_message(:get,"#{gru_key}:presume_host_dead_after").to_i
|
233
246
|
dead_after_number_of_seconds > 0 ? dead_after_number_of_seconds : 120
|
data/lib/gru/version.rb
CHANGED
@@ -79,7 +79,9 @@ describe Gru::Adapters::RedisAdapter do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "returns workers with 0 existing workers" do
|
82
|
-
expect(client).to receive(:multi).exactly(3).times.and_yield(client).and_return([0,
|
82
|
+
expect(client).to receive(:multi).exactly(3).times.and_yield(client).and_return([0,-1,3,3])
|
83
|
+
expect(client).to receive(:hset).with("#{gru_key}:global:workers_running",'test_worker', 0)
|
84
|
+
expect(client).to receive(:hget).with("#{gru_key}:global:workers_running",'test_worker').exactly(1).times.and_return(0)
|
83
85
|
expect(client).to receive(:setnx).exactly(3).times.and_return(true)
|
84
86
|
expect(client).to receive(:del).with("#{gru_key}:test_worker").exactly(3).times
|
85
87
|
expect(client).to receive(:get).with("#{gru_key}:rebalance").exactly(3).times
|
@@ -151,6 +153,7 @@ describe Gru::Adapters::RedisAdapter do
|
|
151
153
|
available_workers = adapter.provision_workers
|
152
154
|
expect(available_workers).to eq({'test_worker' => 0})
|
153
155
|
end
|
156
|
+
|
154
157
|
end
|
155
158
|
end
|
156
159
|
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Gillis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.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.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.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: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.1.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: 3.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.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: '0.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: awesome_print
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.0'
|
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: '0.0'
|
97
97
|
description: This is a worker/minion manager using different atomic data stores.
|
@@ -101,7 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- .gitignore
|
104
|
+
- ".gitignore"
|
105
105
|
- Gemfile
|
106
106
|
- LICENSE.txt
|
107
107
|
- README.md
|
@@ -125,21 +125,20 @@ require_paths:
|
|
125
125
|
- lib
|
126
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
requirements:
|
133
|
-
- -
|
133
|
+
- - ">="
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.5.1
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: An atomic worker/minion manager.
|
142
142
|
test_files:
|
143
143
|
- spec/gru/adapters/redis_adapter_spec.rb
|
144
144
|
- spec/gru/worker_manager_spec.rb
|
145
|
-
has_rdoc:
|