jobba 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -15
- data/lib/jobba/state.rb +4 -4
- data/lib/jobba/version.rb +1 -1
- 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: be04439547ffdf5ad57d5ac3a3279ca10ed0ae5b
|
4
|
+
data.tar.gz: 13de0a5da8c25827bdef5a7dbb99143d3e12427b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1099b20ffe944620cf5d712eea9c64410da0fa877ac9695c27dfee3cf557f2c348eeeaf9ca44088fa4c42fe0f1e8b6f1d27541412e0211ad5f7d900a1625baaa
|
7
|
+
data.tar.gz: a041d7540f6518291bd659b881dd03fc74d942529786b7c70145c9c327b6261facb44d489c7fd33672fe23a29d446c799ce362494d4d018f1c9824c9d4c5c64a
|
data/README.md
CHANGED
@@ -19,6 +19,8 @@ or
|
|
19
19
|
$> gem install jobba
|
20
20
|
```
|
21
21
|
|
22
|
+
Semantic versioning will begin with version `2.0.0`.
|
23
|
+
|
22
24
|
## Configuration
|
23
25
|
|
24
26
|
To configure Jobba, put the following code in your applications
|
@@ -54,7 +56,7 @@ call:
|
|
54
56
|
Jobba::Status.find!(id)
|
55
57
|
```
|
56
58
|
|
57
|
-
The
|
59
|
+
The result of `find!` will start in an `unknown` state if the ID doesn't exist in Redis.
|
58
60
|
|
59
61
|
## Basic Use with ActiveJob
|
60
62
|
|
@@ -76,7 +78,7 @@ class MyJob < ::ActiveJob::Base
|
|
76
78
|
def perform(*args, &block)
|
77
79
|
# Pop the ID argument added by perform_later and get a Status
|
78
80
|
status = Jobba::Status.find!(args.pop)
|
79
|
-
status.
|
81
|
+
status.started!
|
80
82
|
|
81
83
|
# ... do stuff ...
|
82
84
|
|
@@ -91,7 +93,7 @@ One of the main functions of Jobba is to let a job advance its status through a
|
|
91
93
|
|
92
94
|
* `unqueued`
|
93
95
|
* `queued`
|
94
|
-
* `
|
96
|
+
* `started`
|
95
97
|
* `succeeded`
|
96
98
|
* `failed`
|
97
99
|
* `killed`
|
@@ -100,7 +102,7 @@ One of the main functions of Jobba is to let a job advance its status through a
|
|
100
102
|
Put a `Status` into one of these states by calling `that_state!`, e.g.
|
101
103
|
|
102
104
|
```ruby
|
103
|
-
my_state.
|
105
|
+
my_state.started!
|
104
106
|
```
|
105
107
|
|
106
108
|
The `unqueued` state is entered when a `Status` is first created. The `unknown` state is entered when `find!(id)` is called but the `id` is not known. You can re-enter these states with the `!` methods, but note that the `recorded_at` timestamp will not be updated.
|
@@ -111,7 +113,7 @@ The **first time a state is entered**, a timestamp is recorded for that state.
|
|
111
113
|
|-------|-----------|
|
112
114
|
|unqueued | recorded_at |
|
113
115
|
|queued | queued_at |
|
114
|
-
|
|
116
|
+
|started | started_at |
|
115
117
|
|succeeded | succeeded_at |
|
116
118
|
|failed | failed_at |
|
117
119
|
|killed | killed_at |
|
@@ -162,7 +164,7 @@ If you want to be able to query for all statuses that take a certain argument as
|
|
162
164
|
my_status.add_job_arg(arg_name, arg)
|
163
165
|
```
|
164
166
|
|
165
|
-
where `arg_name` is what the argument is called in your job (e.g. `"input_1"`) and `arg` is a way to identify the argument (e.g. `"gid://app/Person/72").
|
167
|
+
where `arg_name` is what the argument is called in your job (e.g. `"input_1"`) and `arg` is a way to identify the argument (e.g. `"gid://app/Person/72"`).
|
166
168
|
|
167
169
|
You probably will only want to track complex arguments, e.g. models in your application. E.g. you could have a `Book` model and a `PublishBook` background job and you may want to see all of the `PublishBook` jobs that have status for the `Book` with ID `53`.
|
168
170
|
|
@@ -182,7 +184,7 @@ my_status.kill_requested?
|
|
182
184
|
|
183
185
|
and if that returns `true`, it can attempt to gracefully terminate itself.
|
184
186
|
|
185
|
-
Note that when a kill is requested, the job will continue to be in some other state (e.g. `
|
187
|
+
Note that when a kill is requested, the job will continue to be in some other state (e.g. `started`) until it is in fact killed, at which point the job should call:
|
186
188
|
|
187
189
|
```ruby
|
188
190
|
my_status.killed!
|
@@ -217,7 +219,7 @@ A `Status` object also methods to check if it is in certain states:
|
|
217
219
|
* `reload!`
|
218
220
|
* `unqueued?`
|
219
221
|
* `queued?`
|
220
|
-
* `
|
222
|
+
* `started?`
|
221
223
|
* `succeeded?`
|
222
224
|
* `failed?`
|
223
225
|
* `killed?`
|
@@ -228,11 +230,11 @@ And two conveience methods for checking groups of states:
|
|
228
230
|
* `completed?`
|
229
231
|
* `incomplete?`
|
230
232
|
|
231
|
-
You can also call `reload!` on a `Status` to have it reset its state to what is stored in
|
233
|
+
You can also call `reload!` on a `Status` to have it reset its state to what is stored in Redis.
|
232
234
|
|
233
235
|
## Deleting Job Statuses
|
234
236
|
|
235
|
-
Once jobs are completed or otherwise no longer interesting, it'd be nice to clear them out of
|
237
|
+
Once jobs are completed or otherwise no longer interesting, it'd be nice to clear them out of Redis. You can do this with:
|
236
238
|
|
237
239
|
```ruby
|
238
240
|
my_status.delete # freaks out if `my_status` isn't complete
|
@@ -250,7 +252,7 @@ Jobba has an activerecord-like query interface for finding Status objects.
|
|
250
252
|
```ruby
|
251
253
|
Jobba.where(state: :unqueued)
|
252
254
|
Jobba.where(state: :queued)
|
253
|
-
Jobba.where(state: :
|
255
|
+
Jobba.where(state: :started)
|
254
256
|
Jobba.where(state: :succeeded)
|
255
257
|
Jobba.where(state: :failed)
|
256
258
|
Jobba.where(state: :killed)
|
@@ -261,13 +263,13 @@ Two convenience "state" queries have been added:
|
|
261
263
|
|
262
264
|
```ruby
|
263
265
|
Jobba.where(state: :completed) # includes succeeded, failed
|
264
|
-
Jobba.where(state: :incomplete) # includes unqueued, queued,
|
266
|
+
Jobba.where(state: :incomplete) # includes unqueued, queued, started, killed
|
265
267
|
```
|
266
268
|
|
267
269
|
You can query combinations of states too:
|
268
270
|
|
269
271
|
```ruby
|
270
|
-
Jobba.where(state: [:queued, :
|
272
|
+
Jobba.where(state: [:queued, :started])
|
271
273
|
```
|
272
274
|
|
273
275
|
**State Timestamp**
|
@@ -328,7 +330,7 @@ When you have a query you can run the following methods on it. These act like w
|
|
328
330
|
* `empty?`
|
329
331
|
* `count`
|
330
332
|
|
331
|
-
`empty?` and `count` are performed in
|
333
|
+
`empty?` and `count` are performed in Redis without bringing back all query results to Ruby.
|
332
334
|
|
333
335
|
You can also call two special methods directly on `Jobba`:
|
334
336
|
|
@@ -363,7 +365,7 @@ Note that, in operations having to do with time, this gem ignores anything beyon
|
|
363
365
|
|
364
366
|
### Efficiency
|
365
367
|
|
366
|
-
Jobba strives to do all of its operations as efficiently as possible using built-in
|
368
|
+
Jobba strives to do all of its operations as efficiently as possible using built-in Redis operations. If you find a place where the efficiency can be improved, please submit an issue or a pull request.
|
367
369
|
|
368
370
|
## TODO
|
369
371
|
|
data/lib/jobba/state.rb
CHANGED
@@ -13,7 +13,7 @@ class Jobba::State
|
|
13
13
|
|
14
14
|
UNQUEUED = new('unqueued', 'recorded_at')
|
15
15
|
QUEUED = new('queued', 'queued_at')
|
16
|
-
|
16
|
+
STARTED = new('started', 'started_at')
|
17
17
|
SUCCEEDED = new('succeeded', 'succeeded_at')
|
18
18
|
FAILED = new('failed', 'failed_at')
|
19
19
|
KILLED = new('killed', 'killed_at')
|
@@ -22,7 +22,7 @@ class Jobba::State
|
|
22
22
|
ALL = [
|
23
23
|
UNQUEUED,
|
24
24
|
QUEUED,
|
25
|
-
|
25
|
+
STARTED,
|
26
26
|
SUCCEEDED,
|
27
27
|
FAILED,
|
28
28
|
KILLED,
|
@@ -37,14 +37,14 @@ class Jobba::State
|
|
37
37
|
INCOMPLETE = [
|
38
38
|
UNQUEUED,
|
39
39
|
QUEUED,
|
40
|
-
|
40
|
+
STARTED,
|
41
41
|
KILLED
|
42
42
|
].freeze
|
43
43
|
|
44
44
|
ENTERABLE = [
|
45
45
|
UNQUEUED,
|
46
46
|
QUEUED,
|
47
|
-
|
47
|
+
STARTED,
|
48
48
|
SUCCEEDED,
|
49
49
|
FAILED,
|
50
50
|
KILLED,
|
data/lib/jobba/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|