disque 0.0.5 → 0.0.6
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 +4 -0
- data/disque.gemspec +1 -1
- data/lib/disque.rb +10 -12
- data/tests/disque_test.rb +13 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56a16e44f931c9df3d8034e20f33ac0aea958236
|
4
|
+
data.tar.gz: 228513e14dd5e84c7bb75b3a11fae24b11ef0d79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abee6e5004f76d9a8dea568af92c3875a515ff409e96e122a4cfa49435cf08f5b5f3e1d087c7d9f72d94d47a571c6216ba6e79b7ba9f56ac48e45576a5295c22
|
7
|
+
data.tar.gz: 64960b88004ac406d5ef67bf7ca9776892e3fe7ef95c72372d6e8ae58922f2e7c4303c899038251d534edcca871dc4fccbbefe9564af131f2cb316a61e7b6215
|
data/CHANGELOG
CHANGED
data/disque.gemspec
CHANGED
data/lib/disque.rb
CHANGED
@@ -42,6 +42,8 @@ class Disque
|
|
42
42
|
# Operations counter
|
43
43
|
@count = 0
|
44
44
|
|
45
|
+
@hosts = hosts
|
46
|
+
|
45
47
|
# Known nodes
|
46
48
|
@nodes = Hash.new
|
47
49
|
|
@@ -57,7 +59,7 @@ class Disque
|
|
57
59
|
# Preferred client prefix
|
58
60
|
@prefix = nil
|
59
61
|
|
60
|
-
explore!
|
62
|
+
explore!
|
61
63
|
end
|
62
64
|
|
63
65
|
def url(host)
|
@@ -70,12 +72,12 @@ class Disque
|
|
70
72
|
|
71
73
|
# Collect the list of nodes and keep a connection to the
|
72
74
|
# node that provided that information.
|
73
|
-
def explore!
|
75
|
+
def explore!
|
74
76
|
|
75
77
|
# Reset nodes
|
76
78
|
@nodes.clear
|
77
79
|
|
78
|
-
hosts.each do |host|
|
80
|
+
@hosts.each do |host|
|
79
81
|
begin
|
80
82
|
@scout.configure(url(host))
|
81
83
|
|
@@ -87,18 +89,14 @@ class Disque
|
|
87
89
|
# our stats are based on that.
|
88
90
|
@prefix = result[1][0,8]
|
89
91
|
|
90
|
-
#
|
91
|
-
@
|
92
|
+
# Populate cache
|
93
|
+
@nodes[@prefix] = host
|
92
94
|
|
93
|
-
#
|
94
|
-
|
95
|
-
@nodes[node_id[0,8]] = sprintf("%s:%s", hostname, port)
|
96
|
-
end
|
95
|
+
# Connect the main client to the last scouted node
|
96
|
+
@client.configure(@scout.url)
|
97
97
|
|
98
98
|
@scout.quit
|
99
99
|
|
100
|
-
break
|
101
|
-
|
102
100
|
rescue *ECONN
|
103
101
|
$stderr.puts($!.inspect)
|
104
102
|
end
|
@@ -138,7 +136,7 @@ class Disque
|
|
138
136
|
def call(*args)
|
139
137
|
@client.call!(*args)
|
140
138
|
rescue *ECONN
|
141
|
-
explore!
|
139
|
+
explore!
|
142
140
|
retry
|
143
141
|
end
|
144
142
|
|
data/tests/disque_test.rb
CHANGED
@@ -124,7 +124,7 @@ test "add jobs with other parameters" do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
test "connect to the best node" do
|
127
|
-
c1 = Disque.new([DISQUE_GOOD_NODES[0]], cycle: 2, auth: "test")
|
127
|
+
c1 = Disque.new([DISQUE_GOOD_NODES[1], DISQUE_GOOD_NODES[0]], cycle: 2, auth: "test")
|
128
128
|
c2 = Disque.new([DISQUE_GOOD_NODES[1]], cycle: 2, auth: "test")
|
129
129
|
|
130
130
|
assert c1.prefix != c2.prefix
|
@@ -146,8 +146,8 @@ test "connect to the best node" do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
test "connect to the best node, part 2" do
|
149
|
-
c1 = Disque.new([DISQUE_GOOD_NODES[0]], cycle: 2, auth: "test")
|
150
|
-
c2 = Disque.new([DISQUE_GOOD_NODES[1]], cycle: 2, auth: "test")
|
149
|
+
c1 = Disque.new([DISQUE_GOOD_NODES[1], DISQUE_GOOD_NODES[0]], cycle: 2, auth: "test")
|
150
|
+
c2 = Disque.new([DISQUE_GOOD_NODES[0], DISQUE_GOOD_NODES[1]], cycle: 2, auth: "test")
|
151
151
|
|
152
152
|
assert c1.prefix != c2.prefix
|
153
153
|
|
@@ -164,7 +164,11 @@ test "connect to the best node, part 2" do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
test "recover after node disconnection" do
|
167
|
-
|
167
|
+
Silencer.start
|
168
|
+
|
169
|
+
c1 = Disque.new([DISQUE_GOOD_NODES[0], DISQUE_BAD_NODES[0]], cycle: 2, auth: "test")
|
170
|
+
|
171
|
+
Silencer.stop
|
168
172
|
|
169
173
|
prefix = c1.prefix
|
170
174
|
|
@@ -178,6 +182,8 @@ test "recover after node disconnection" do
|
|
178
182
|
key != "fake"
|
179
183
|
end
|
180
184
|
|
185
|
+
Silencer.start
|
186
|
+
|
181
187
|
c1.push("q1", "j1", 1000)
|
182
188
|
c1.push("q1", "j2", 1000)
|
183
189
|
c1.push("q1", "j3", 1000)
|
@@ -186,8 +192,11 @@ test "recover after node disconnection" do
|
|
186
192
|
c1.fetch(from: ["q1"])
|
187
193
|
c1.fetch(from: ["q1"])
|
188
194
|
|
195
|
+
Silencer.stop
|
196
|
+
|
189
197
|
# Prefix should stay the same
|
190
198
|
assert_equal prefix, c1.prefix
|
199
|
+
assert_equal "#<Errno::ECONNREFUSED: Can't connect to: disque://:test@127.0.0.1:7710>\n", Silencer.output
|
191
200
|
end
|
192
201
|
|
193
202
|
test "federation" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redic
|