jober 0.3.38 → 0.3.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jober/queue.rb +10 -2
- data/lib/jober/slow_queue.rb +3 -3
- data/lib/jober/version.rb +1 -1
- data/spec/queue_spec.rb +39 -0
- 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: e2f3f5e547d021f6d5a67c7130e74f9ca7c9ae2d
|
4
|
+
data.tar.gz: ca11d9aa10081fea767f4765e2fd26aad566060c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840317e4d7b63637d9418f8e8d7bbcc63590ffc1754869ec22d3751b2d12d858db82a0818cd3a137e6d288679794b13f726f5bda490eca227bbb81e39c378909
|
7
|
+
data.tar.gz: b36c2b7fb372b28de918910fb0db6a69bbca7247e087a5621e0188edf93b7d5f49df62ba855d854592cf17f2bb979ec7481cbb3f5084e5195074fb70c4efa47b
|
data/lib/jober/queue.rb
CHANGED
@@ -41,8 +41,8 @@ class Jober::Queue < Jober::Task
|
|
41
41
|
|
42
42
|
def run
|
43
43
|
cnt = 0
|
44
|
-
while args = pop
|
45
|
-
perform(
|
44
|
+
while @args = pop
|
45
|
+
perform(*@args)
|
46
46
|
cnt += 1
|
47
47
|
|
48
48
|
if stopped
|
@@ -53,4 +53,12 @@ class Jober::Queue < Jober::Task
|
|
53
53
|
end
|
54
54
|
info { "processed total #{cnt}" }
|
55
55
|
end
|
56
|
+
|
57
|
+
def retry_event
|
58
|
+
self.class.dequeue(*@args) if @args
|
59
|
+
end
|
60
|
+
|
61
|
+
def retry_event_later
|
62
|
+
self.class.enqueue(*@args) if @args
|
63
|
+
end
|
56
64
|
end
|
data/lib/jober/slow_queue.rb
CHANGED
@@ -2,9 +2,9 @@ class Jober::SlowQueue < Jober::Queue
|
|
2
2
|
|
3
3
|
# one event per perform
|
4
4
|
def run
|
5
|
-
if args = pop
|
6
|
-
perform(
|
7
|
-
info { "processed event args: #{args.inspect}" }
|
5
|
+
if @args = pop
|
6
|
+
perform(*@args)
|
7
|
+
info { "processed event args: #{@args.inspect}" }
|
8
8
|
else
|
9
9
|
info { "no pending events" }
|
10
10
|
end
|
data/lib/jober/version.rb
CHANGED
data/spec/queue_spec.rb
CHANGED
@@ -13,6 +13,34 @@ class MyQueue < Jober::Queue
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
class MyQueueR2 < Jober::Queue
|
17
|
+
def initialize(*args)
|
18
|
+
super
|
19
|
+
@counter = 0
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :counter
|
23
|
+
|
24
|
+
def perform(x)
|
25
|
+
@counter += x
|
26
|
+
retry_event if @counter < 10
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class MyQueueR3 < Jober::Queue
|
31
|
+
def initialize(*args)
|
32
|
+
super
|
33
|
+
@counter = 0
|
34
|
+
end
|
35
|
+
|
36
|
+
attr_reader :counter
|
37
|
+
|
38
|
+
def perform(x)
|
39
|
+
@counter += x
|
40
|
+
retry_event_later if @counter < 10
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
16
44
|
class Jasdfoadsfjaf < Jober::Queue
|
17
45
|
set_queue_name 'human_name'
|
18
46
|
|
@@ -41,4 +69,15 @@ describe "Queue" do
|
|
41
69
|
10.times { Jasdfoadsfjaf.enqueue }
|
42
70
|
Jober.llens['human_name'].should == 10
|
43
71
|
end
|
72
|
+
|
73
|
+
it "retry_event" do
|
74
|
+
MyQueueR2.enqueue(1)
|
75
|
+
MyQueueR2.new.execute.counter.should == 10
|
76
|
+
end
|
77
|
+
|
78
|
+
it "retry_event_later" do
|
79
|
+
MyQueueR3.enqueue(1)
|
80
|
+
MyQueueR3.new.execute.counter.should == 10
|
81
|
+
end
|
82
|
+
|
44
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jober
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Konstantin Makarchev'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|