coordinator 0.0.8 → 0.0.9
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/README.md +3 -0
- data/lib/coordinator/base.rb +8 -0
- data/lib/coordinator/queue.rb +6 -0
- data/lib/coordinator/version.rb +1 -1
- data/test/unit/base_test.rb +30 -0
- data/test/unit/queue_test.rb +10 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba122b99d0854436ad66722efd17fb50dc1a4d27
|
4
|
+
data.tar.gz: a65bc1f944b110a655a4895ade5f7ec283d2c6f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c229709dd74c66705eec7350e0e6fe712e43e037e0e42179bd605dc1cd660b4427beda31aa493f21ffb2346d98c51a1e46697d12eda8988e5dc4314272368983
|
7
|
+
data.tar.gz: 20da3611c6041f5622f69e29fe22917f4ae461afd866ffd71d89357a8de4b65a0ac7547e9fbe839a8290747e19119d5e105a5ed62977d8a79501c3aea62dc842
|
data/README.md
CHANGED
@@ -33,6 +33,9 @@ Or install it yourself as:
|
|
33
33
|
@coordinator.add_task("medium", 2)
|
34
34
|
@coordinator.add_priority_task("high", 3)
|
35
35
|
|
36
|
+
@coordinator.length_all # returns 3
|
37
|
+
@coordinator.peek_all # returns [3, 2]
|
38
|
+
|
36
39
|
@coordinator.next_task(["high"]) # returns 3
|
37
40
|
@coordinator.next_task(["medium"]) # returns 2
|
38
41
|
|
data/lib/coordinator/base.rb
CHANGED
data/lib/coordinator/queue.rb
CHANGED
data/lib/coordinator/version.rb
CHANGED
data/test/unit/base_test.rb
CHANGED
@@ -7,6 +7,7 @@ describe 'Coordinator::Base' do
|
|
7
7
|
Coordinator::Queue.new("medium"),
|
8
8
|
Coordinator::Queue.new("low")
|
9
9
|
])
|
10
|
+
Redis.current.flushall
|
10
11
|
end
|
11
12
|
|
12
13
|
describe 'adding work' do
|
@@ -36,4 +37,33 @@ describe 'Coordinator::Base' do
|
|
36
37
|
assert_equal 2, @coordinator.next_task(["medium"])
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
describe 'length_all' do
|
42
|
+
it 'returns the total amount of tasks across all queues' do
|
43
|
+
@coordinator.add_task("medium", 1)
|
44
|
+
@coordinator.add_priority_task("medium", 2)
|
45
|
+
@coordinator.add_task("low", 3)
|
46
|
+
@coordinator.add_task("high", 4)
|
47
|
+
assert_equal 4, @coordinator.length_all
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns 0 for no tasks enqueued' do
|
51
|
+
assert_equal 0, @coordinator.length_all
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'peek_all' do
|
56
|
+
it 'returns the top item from each queue' do
|
57
|
+
@coordinator.add_task("medium", 1)
|
58
|
+
@coordinator.add_priority_task("medium", 2)
|
59
|
+
@coordinator.add_task("low", 3)
|
60
|
+
@coordinator.add_task("high", 4)
|
61
|
+
|
62
|
+
assert_equal [2,3,4].sort, @coordinator.peek_all.sort
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns empty array if all queues are empty' do
|
66
|
+
assert_equal [], @coordinator.peek_all
|
67
|
+
end
|
68
|
+
end
|
39
69
|
end
|
data/test/unit/queue_test.rb
CHANGED
@@ -63,4 +63,14 @@ describe "Coordinator::Queue" do
|
|
63
63
|
assert queue.eligible?(3, ["special"]), "override through both"
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
describe "peek" do
|
68
|
+
it "deserialize the top task but leaves it in the queue" do
|
69
|
+
task = {"id" => 123}
|
70
|
+
@queue.add_task(task)
|
71
|
+
|
72
|
+
assert_equal task, @queue.peek
|
73
|
+
assert_equal task, @queue.peek # ensure task is still enqueued
|
74
|
+
end
|
75
|
+
end
|
66
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coordinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Mercier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -136,3 +136,4 @@ test_files:
|
|
136
136
|
- test/unit/parallelism_test.rb
|
137
137
|
- test/unit/queue_test.rb
|
138
138
|
- test/unit/redis_queue_test.rb
|
139
|
+
has_rdoc:
|