coordinator 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/lib/coordinator/base.rb +4 -4
- data/lib/coordinator/redis_queue.rb +5 -5
- data/lib/coordinator/version.rb +1 -1
- data/test/unit/parallelism_test.rb +4 -4
- 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: 71eb76d378d1147cdbfd7e78d875f32f9d83565b
|
4
|
+
data.tar.gz: 6f6be3352fe457ebf328eb57f207a1cf41a677e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88bbe072e9a127f64c29b60fa2c48f13dafa2b7c4f15fee453344edf3c9af75e7a12243995ea48c4d63fb652123da1e7497d21a53e9741cc2f682b2886c91daa
|
7
|
+
data.tar.gz: 69fe1fa61e8640205c213bf6b91a8e768007d148352441a77ac071a167b95909c6fdaa201deccf2cdd6bddc8b15496eb65f0e068d5bf82bbc25c41a3e40e4e32
|
data/lib/coordinator/base.rb
CHANGED
@@ -31,10 +31,10 @@ module Coordinator
|
|
31
31
|
def info(skill)
|
32
32
|
queue = queue_for_skill(skill)
|
33
33
|
{
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
"name" => queue.name,
|
35
|
+
"capacity" => queue.capacity,
|
36
|
+
"count" => queue.length,
|
37
|
+
"items" => queue.items
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
@@ -22,7 +22,7 @@ module Coordinator
|
|
22
22
|
|
23
23
|
def pop
|
24
24
|
data = @redis.lpop(@queue_name)
|
25
|
-
|
25
|
+
deserialize(data)
|
26
26
|
end
|
27
27
|
|
28
28
|
def remove(item)
|
@@ -32,7 +32,7 @@ module Coordinator
|
|
32
32
|
|
33
33
|
def peek
|
34
34
|
data = @redis.lrange(@queue_name, 0, 0).first
|
35
|
-
|
35
|
+
deserialize(data)
|
36
36
|
end
|
37
37
|
|
38
38
|
def length
|
@@ -41,7 +41,7 @@ module Coordinator
|
|
41
41
|
|
42
42
|
def capacity
|
43
43
|
data = @redis.get(@capacity_name)
|
44
|
-
|
44
|
+
deserialize(data)
|
45
45
|
end
|
46
46
|
|
47
47
|
def capacity=(capacity)
|
@@ -49,7 +49,7 @@ module Coordinator
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def items
|
52
|
-
@redis.lrange(@queue_name, 0, length)
|
52
|
+
@redis.lrange(@queue_name, 0, length).map { |i| deserialize(i) }
|
53
53
|
end
|
54
54
|
|
55
55
|
private
|
@@ -62,7 +62,7 @@ module Coordinator
|
|
62
62
|
item.is_a?(String) ? item : item.to_json
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def deserialize(item)
|
66
66
|
return item if item.nil?
|
67
67
|
return item.to_i if item.to_i.to_s == item
|
68
68
|
begin
|
data/lib/coordinator/version.rb
CHANGED
@@ -13,8 +13,8 @@ describe 'ParallelismTest' do
|
|
13
13
|
|
14
14
|
it 'works syncronously' do
|
15
15
|
125.times { perform_work }
|
16
|
-
assert_equal [], @coordinator.info("tasks")[
|
17
|
-
array_equal(@tasks, @coordinator.info("completed_tasks")[
|
16
|
+
assert_equal [], @coordinator.info("tasks")["items"]
|
17
|
+
array_equal(@tasks, @coordinator.info("completed_tasks")["items"])
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'works in parallel' do
|
@@ -30,8 +30,8 @@ describe 'ParallelismTest' do
|
|
30
30
|
end
|
31
31
|
workers.each { |w| w.join }
|
32
32
|
|
33
|
-
assert_equal [], @coordinator.info("tasks")[
|
34
|
-
array_equal(@tasks, @coordinator.info("completed_tasks")[
|
33
|
+
assert_equal [], @coordinator.info("tasks")["items"]
|
34
|
+
array_equal(@tasks, @coordinator.info("completed_tasks")["items"])
|
35
35
|
end
|
36
36
|
|
37
37
|
def perform_work(i=nil)
|