resque-lonely_job 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +2 -0
- data/README.md +40 -5
- data/lib/resque-lonely_job/version.rb +1 -1
- data/resque-lonely_job.gemspec +2 -3
- metadata +35 -43
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ODJhOTg3YWYyZjRiZTcyMmZlMmNhZjA4NjRjNzc4YmY5ZGNhNWI0ZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 77d6fb9e55406f71e625a51f3aed732858c53c30
|
4
|
+
data.tar.gz: 5428f1070c91a492eefd4b13eaf9ba9bb4d404fa
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
N2RkODI1YjQzMDg0MjA0YTQ4ZDRiNTVkNWQ3YTk2YTk4MGU3Y2ZkNmYwMWI3
|
11
|
-
YjE2Yzc2NjBkMzFmZmI2MjUwNjBmY2MzZWIyNmM0YjVmZjQ0N2I=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTBhZjY2MmZjNGE5MGZhNjYwYWFmNDViZWIzMzVmNzg0Y2I3OTUxMjA5YTcy
|
14
|
-
ZTc1YjE5MGI5ZmVjN2ZlNTM4YjBkOWRlZDYzMDQxN2E1NDFjZWM0NDc5OGY1
|
15
|
-
NDJiZmExNjM0MTAxMmM3OGQwZjgwNmQ4NWRkMWFiZTgxM2Q0N2Q=
|
6
|
+
metadata.gz: 5014e12936d857fec3009b2c8b017689a4c3e25765f3122a196d984d3fbc9fa07c1cf4591de26d5801716104b67b6948d08fdc59e52a8fb5aff73e91970b24b0
|
7
|
+
data.tar.gz: 57fbd6bcb2a2189bc382814751f29efd4b14071e059a4e50087a0c5e6e8ad8f7109d640ce0755bfd48566d7df40646430c2fdfc2415f83378d4615e7a2309ef1
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/wallace/resque-lonely_job.png)](https://travis-ci.org/wallace/resque-lonely\_job)
|
4
4
|
|
5
|
-
A [Resque](https://github.com/resque/resque) plugin
|
6
|
-
|
5
|
+
A [Resque](https://github.com/resque/resque) plugin that implements [Semantic
|
6
|
+
Versioning](http://semver.org/).
|
7
|
+
|
8
|
+
Version 1.x Requires Resque >= 1.20.0 and < 1.25.0.
|
9
|
+
|
10
|
+
Requires a version of MRI Ruby >= 1.9.3.
|
7
11
|
|
8
12
|
Ensures that for a given queue, only one worker is working on a job at any given
|
9
13
|
time.
|
@@ -35,7 +39,7 @@ Or install it yourself as:
|
|
35
39
|
|
36
40
|
#### Example #1 -- One job running per queue
|
37
41
|
|
38
|
-
require 'resque
|
42
|
+
require 'resque-lonely_job'
|
39
43
|
|
40
44
|
class StrictlySerialJob
|
41
45
|
extend Resque::Plugins::LonelyJob
|
@@ -54,7 +58,7 @@ Let's say you want the serial constraint to apply at a more granular
|
|
54
58
|
level. Instead of applying at the queue level, you can overwrite the .redis\_key
|
55
59
|
method.
|
56
60
|
|
57
|
-
require 'resque
|
61
|
+
require 'resque-lonely_job'
|
58
62
|
|
59
63
|
class StrictlySerialJob
|
60
64
|
extend Resque::Plugins::LonelyJob
|
@@ -112,7 +116,38 @@ where you have three jobs in the queue with two resque workers:
|
|
112
116
|
|
113
117
|
#### Example #3 -- One job running per user-defined attribute with job ordering preserved
|
114
118
|
|
115
|
-
|
119
|
+
The secret to preserving job order semantics is to remove critical data from the
|
120
|
+
resque job and store data in a separate redis list. Part of a running job's
|
121
|
+
responsibility will be to grab data off of the separate redis list needed for it
|
122
|
+
to complete its job.
|
123
|
+
|
124
|
+
+---------------------------------------------------+
|
125
|
+
| :serial_work for jobs associated with key A |
|
126
|
+
|---------------------------------------------------|
|
127
|
+
| data x | data y | data z | ... |
|
128
|
+
+---------------------------------------------------+
|
129
|
+
|
130
|
+
+---------------------------------------------------+
|
131
|
+
| :serial_work for jobs associated with key B |
|
132
|
+
|---------------------------------------------------|
|
133
|
+
| data m | data n | data o | ... |
|
134
|
+
+---------------------------------------------------+
|
135
|
+
|
136
|
+
+---------------------------------------------------+
|
137
|
+
| :serial_work |
|
138
|
+
|---------------------------------------------------|
|
139
|
+
| | | | |
|
140
|
+
| redis_key: | redis_key: | redis_key: | ... |
|
141
|
+
| A | A | B | |
|
142
|
+
| | | | |
|
143
|
+
| job 1 | job 2 | job 3 | |
|
144
|
+
+---------------------------------------------------+
|
145
|
+
|
146
|
+
It now doesn't matter whether job 1 and job 2 are re-ordered as whichever goes
|
147
|
+
first will perform an atomic pop on the redis list that contains the data needed
|
148
|
+
for its job (data x, data y, data z).
|
149
|
+
|
150
|
+
*NOTE*: Worker starvation and fairness is still possible as in Example 2.
|
116
151
|
|
117
152
|
## Contributing
|
118
153
|
|
data/resque-lonely_job.gemspec
CHANGED
@@ -14,11 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.require_paths = ["lib"]
|
15
15
|
gem.version = Resque::Plugins::LonelyJob::VERSION
|
16
16
|
|
17
|
-
gem.add_dependency 'resque', '>= 1.
|
18
|
-
gem.add_development_dependency 'mock_redis'
|
17
|
+
gem.add_dependency 'resque', '>= 1.2'
|
18
|
+
gem.add_development_dependency 'mock_redis'
|
19
19
|
gem.add_development_dependency 'rake'
|
20
20
|
gem.add_development_dependency 'rspec'
|
21
|
-
gem.add_development_dependency 'debugger'
|
22
21
|
gem.add_development_dependency 'timecop'
|
23
22
|
|
24
23
|
gem.description = <<desc
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-lonely_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan R. Wallace
|
@@ -14,97 +14,89 @@ dependencies:
|
|
14
14
|
name: resque
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
20
|
-
- - <
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.25.0
|
19
|
+
version: '1.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.20.0
|
30
|
-
- - <
|
24
|
+
- - '>='
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
26
|
+
version: '1.2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: mock_redis
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- -
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.4.1
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.4.1
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rake
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
31
|
+
- - '>='
|
52
32
|
- !ruby/object:Gem::Version
|
53
33
|
version: '0'
|
54
34
|
type: :development
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
37
|
requirements:
|
58
|
-
- -
|
38
|
+
- - '>='
|
59
39
|
- !ruby/object:Gem::Version
|
60
40
|
version: '0'
|
61
41
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
42
|
+
name: rake
|
63
43
|
requirement: !ruby/object:Gem::Requirement
|
64
44
|
requirements:
|
65
|
-
- -
|
45
|
+
- - '>='
|
66
46
|
- !ruby/object:Gem::Version
|
67
47
|
version: '0'
|
68
48
|
type: :development
|
69
49
|
prerelease: false
|
70
50
|
version_requirements: !ruby/object:Gem::Requirement
|
71
51
|
requirements:
|
72
|
-
- -
|
52
|
+
- - '>='
|
73
53
|
- !ruby/object:Gem::Version
|
74
54
|
version: '0'
|
75
55
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
56
|
+
name: rspec
|
77
57
|
requirement: !ruby/object:Gem::Requirement
|
78
58
|
requirements:
|
79
|
-
- -
|
59
|
+
- - '>='
|
80
60
|
- !ruby/object:Gem::Version
|
81
61
|
version: '0'
|
82
62
|
type: :development
|
83
63
|
prerelease: false
|
84
64
|
version_requirements: !ruby/object:Gem::Requirement
|
85
65
|
requirements:
|
86
|
-
- -
|
66
|
+
- - '>='
|
87
67
|
- !ruby/object:Gem::Version
|
88
68
|
version: '0'
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: timecop
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
92
72
|
requirements:
|
93
|
-
- -
|
73
|
+
- - '>='
|
94
74
|
- !ruby/object:Gem::Version
|
95
75
|
version: '0'
|
96
76
|
type: :development
|
97
77
|
prerelease: false
|
98
78
|
version_requirements: !ruby/object:Gem::Requirement
|
99
79
|
requirements:
|
100
|
-
- -
|
80
|
+
- - '>='
|
101
81
|
- !ruby/object:Gem::Version
|
102
82
|
version: '0'
|
103
|
-
description:
|
104
|
-
at any given time
|
105
|
-
|
106
|
-
|
107
|
-
|
83
|
+
description: |
|
84
|
+
Ensures that for a given queue, only one worker is working on a job at any given time.
|
85
|
+
|
86
|
+
Example:
|
87
|
+
|
88
|
+
require 'resque/plugins/lonely_job'
|
89
|
+
|
90
|
+
class StrictlySerialJob
|
91
|
+
extend Resque::Plugins::LonelyJob
|
92
|
+
|
93
|
+
@queue = :serial_work
|
94
|
+
|
95
|
+
def self.perform
|
96
|
+
# only one at a time in this block, no parallelism allowed for this
|
97
|
+
# particular queue
|
98
|
+
end
|
99
|
+
end
|
108
100
|
email:
|
109
101
|
- jonathan.wallace@gmail.com
|
110
102
|
executables: []
|
@@ -131,17 +123,17 @@ require_paths:
|
|
131
123
|
- lib
|
132
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
125
|
requirements:
|
134
|
-
- -
|
126
|
+
- - '>='
|
135
127
|
- !ruby/object:Gem::Version
|
136
128
|
version: '0'
|
137
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
130
|
requirements:
|
139
|
-
- -
|
131
|
+
- - '>='
|
140
132
|
- !ruby/object:Gem::Version
|
141
133
|
version: '0'
|
142
134
|
requirements: []
|
143
135
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.0.14
|
145
137
|
signing_key:
|
146
138
|
specification_version: 4
|
147
139
|
summary: A resque plugin that ensures that only one job for a given queue will be
|