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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00c159d15e3e82299c7bab18a5a9793925955a09
4
- data.tar.gz: c59fe0b176b51fc601e04a647b73209fd0519e62
3
+ metadata.gz: e2f3f5e547d021f6d5a67c7130e74f9ca7c9ae2d
4
+ data.tar.gz: ca11d9aa10081fea767f4765e2fd26aad566060c
5
5
  SHA512:
6
- metadata.gz: b70718209990268efaa926bf9044d1bccf52cc010b3d215f365607a0771dd2461025749a9cdb77797f5dd4ded4b1da59e33c3af7bc49fc3c7354fca9b7f06cf3
7
- data.tar.gz: 99c68a86e99ec22e92b480abcd9d6e61a627ba31f13ff0f38a0591b59fbfb24f9fe62957d071ff4a7c0c77c4053439edd8fb69e0266fffe076f015ade2b59404
6
+ metadata.gz: 840317e4d7b63637d9418f8e8d7bbcc63590ffc1754869ec22d3751b2d12d858db82a0818cd3a137e6d288679794b13f726f5bda490eca227bbb81e39c378909
7
+ data.tar.gz: b36c2b7fb372b28de918910fb0db6a69bbca7247e087a5621e0188edf93b7d5f49df62ba855d854592cf17f2bb979ec7481cbb3f5084e5195074fb70c4efa47b
@@ -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(*args)
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
@@ -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(*args)
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
@@ -1,3 +1,3 @@
1
1
  module Jober
2
- VERSION = "0.3.38"
2
+ VERSION = "0.3.39"
3
3
  end
@@ -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.38
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-29 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis