sucker_punch 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/sucker_punch/queue.rb +5 -0
- data/lib/sucker_punch/version.rb +1 -1
- data/spec/sucker_punch/queue_spec.rb +12 -0
- 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: a6a250f32e588a9b931f776dd670522ca0ec3ff7
|
4
|
+
data.tar.gz: 7be73d1af367060749480ea2eed8ad637beb8ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ca879a7efc7732acb5d2dedcea87fa25408e5982ad9d457bece8793b6474a03e2253aa44043350e8ed60c5f3686d0978a749eb788c84e530fab7eea83e1cd1
|
7
|
+
data.tar.gz: 8cdd511604d7422b883fc71f2a840f217ef881f3ec65cde8916bd916b76383008043ef87f4c4dc28f4357b6ee8195380bce181009dc3e62be4680c42f88bd971
|
data/CHANGES.md
CHANGED
data/lib/sucker_punch/queue.rb
CHANGED
@@ -6,6 +6,8 @@ module SuckerPunch
|
|
6
6
|
attr_accessor :pool
|
7
7
|
|
8
8
|
DEFAULT_OPTIONS = { workers: 2 }
|
9
|
+
class MaxWorkersExceeded < StandardError; end
|
10
|
+
class NotEnoughWorkers < StandardError; end
|
9
11
|
|
10
12
|
def self.find(klass)
|
11
13
|
queue = self.new(klass)
|
@@ -19,6 +21,9 @@ module SuckerPunch
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def register(workers = DEFAULT_OPTIONS[:workers] )
|
24
|
+
raise MaxWorkersExceeded if workers > 100
|
25
|
+
raise NotEnoughWorkers if workers < 1
|
26
|
+
|
22
27
|
@mutex.synchronize {
|
23
28
|
unless registered?
|
24
29
|
initialize_celluloid_pool(workers)
|
data/lib/sucker_punch/version.rb
CHANGED
@@ -43,6 +43,18 @@ describe SuckerPunch::Queue do
|
|
43
43
|
queues = SuckerPunch::Queues.all
|
44
44
|
expect(queues.size).to be(1)
|
45
45
|
end
|
46
|
+
|
47
|
+
context "when too many workers are specified" do
|
48
|
+
it "raises a MaxWorkersExceeded exception" do
|
49
|
+
expect{ queue.register(101) }.to raise_error(SuckerPunch::Queue::MaxWorkersExceeded)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when too few workers are specified" do
|
54
|
+
it "raises a NotEnoughWorkers exception" do
|
55
|
+
expect{ queue.register(0) }.to raise_error(SuckerPunch::Queue::NotEnoughWorkers)
|
56
|
+
end
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
48
60
|
describe "#registered?" do
|