cyclop 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -73,7 +73,7 @@ Usage
73
73
  * Requeue a failed job:
74
74
 
75
75
  job = Cyclop.failed.first
76
- job.requeue!
76
+ job.requeue
77
77
 
78
78
  * Start a worker:
79
79
 
@@ -165,6 +165,12 @@ module Cyclop
165
165
  } if exception
166
166
  collection.update selector, update, :safe => true
167
167
  end
168
+
169
+ def requeue
170
+ self.attempts, self.failed, self.locked_at = 0, false, nil
171
+ update = {attempts: attempts, failed: failed, locked_at: locked_at}
172
+ collection.update({_id: _id}, {"$set" => update}, :safe => true)
173
+ end
168
174
 
169
175
  private
170
176
  def self.collection
@@ -1,3 +1,3 @@
1
1
  module Cyclop
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -270,4 +270,31 @@ describe Cyclop::Job do
270
270
  end
271
271
  end
272
272
  end
273
+ describe "#requeue" do
274
+ let(:email_job_failed) { Cyclop::Job.create queue: "email", :locked_by => "anotherid", :locked_at => Time.now.utc, attempts: 1, failed: true }
275
+
276
+ it "can't be taken before requeue" do
277
+ Cyclop::Job.next(locked_by: "myid").should be_nil
278
+ end
279
+
280
+ it "resets failed to false" do
281
+ email_job_failed.requeue
282
+ email_job_failed.failed.should be_false
283
+ end
284
+
285
+ it "resets attemps to 0" do
286
+ email_job_failed.requeue
287
+ email_job_failed.attempts.should == 0
288
+ end
289
+
290
+ it "resets locked_at to nil" do
291
+ email_job_failed.requeue
292
+ email_job_failed.locked_at.should == nil
293
+ end
294
+
295
+ it "can be taken again after requeue" do
296
+ email_job_failed.requeue
297
+ Cyclop::Job.next(locked_by: "myid").should == email_job_failed
298
+ end
299
+ end
273
300
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,12 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-06-01 00:00:00.000000000 +02:00
13
+ date: 2011-06-09 00:00:00.000000000 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bson_ext
18
- requirement: &2162229520 !ruby/object:Gem::Requirement
18
+ requirement: &2165985760 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 1.3.1
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2162229520
26
+ version_requirements: *2165985760
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongo
29
- requirement: &2162229000 !ruby/object:Gem::Requirement
29
+ requirement: &2165985240 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 1.3.1
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2162229000
37
+ version_requirements: *2165985240
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: posix-spawn
40
- requirement: &2162228520 !ruby/object:Gem::Requirement
40
+ requirement: &2165984760 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: 0.3.6
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2162228520
48
+ version_requirements: *2165984760
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
- requirement: &2162228040 !ruby/object:Gem::Requirement
51
+ requirement: &2165984280 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 0.8.7
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *2162228040
59
+ version_requirements: *2165984280
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rspec
62
- requirement: &2162227560 !ruby/object:Gem::Requirement
62
+ requirement: &2165983800 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: 2.6.0
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *2162227560
70
+ version_requirements: *2165983800
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rocco
73
- requirement: &2162227080 !ruby/object:Gem::Requirement
73
+ requirement: &2165983320 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '0.7'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *2162227080
81
+ version_requirements: *2165983320
82
82
  description: Job queue with MongoDB with emphasis on never losing any task even if
83
83
  worker fails hard (segfault).
84
84
  email: