dj_one 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/dj_one.rb +3 -3
- data/lib/dj_one/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: ff6e898db244d0284e3abd9a1f8cb64b570fbee2
|
4
|
+
data.tar.gz: efced02197d53c28da16261483cb3b872019e805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a821fd070dea46294fcb4a476bbfe86647ce0f6102f8f936a230d1424a00fe66b479504da3685251510068fb28ff9a6a63b278225b366ba83b19a1e1f6f162da
|
7
|
+
data.tar.gz: 6baaedfa4d1c2c0ebbf28d80cc8757f152fc3f63d90f8291f3ccc1f984c4386221bcbb844258054ac5e88aa770e7c7ac3cf44b3ac40c26ffadaf4f08f9355e42
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/piotrj/dj_one)
|
4
4
|
|
5
|
+
If you want to get rid of duplicated DelayedJobs - DjOne is for you.
|
6
|
+
|
5
7
|
## What is DjOne
|
6
8
|
|
7
9
|
DjOne ensures that you don't have duplicate jobs scheduled or running. When you schedule a job as a reaction to some event you may end up with multiple jobs that will be basically doing the same thing.
|
@@ -32,6 +34,9 @@ Well, so here is the thing. You don't know at which point of operation JobA1 is.
|
|
32
34
|
|
33
35
|
## Installation
|
34
36
|
|
37
|
+
This guide assumes that you have delayed_job set up in your project (along with ActiveRecord adapter for DelayedJobs).
|
38
|
+
If not follow the guide from here: https://github.com/collectiveidea/delayed_job.
|
39
|
+
|
35
40
|
1. Add `dj_one` to your Gemfile.
|
36
41
|
|
37
42
|
```ruby
|
@@ -39,7 +44,7 @@ Well, so here is the thing. You don't know at which point of operation JobA1 is.
|
|
39
44
|
```
|
40
45
|
|
41
46
|
2. Run `bundle install`.
|
42
|
-
3.
|
47
|
+
3. Run `rails g delayed_job:add_dj_one`. This will generate a migration that will add a column and unique index that will help us ensure uniqueness of jobs.
|
43
48
|
4. Run `rake db:migrate`
|
44
49
|
5. Add DjOne as a plugin in your DelayedJob initializer
|
45
50
|
```ruby
|
data/lib/dj_one.rb
CHANGED
@@ -23,7 +23,7 @@ module DjOne
|
|
23
23
|
|
24
24
|
def enqueue(job, &proceed)
|
25
25
|
job.unique_id = get_attribute(job, :enqueue_id)
|
26
|
-
proceed.call
|
26
|
+
proceed.call(job)
|
27
27
|
rescue ActiveRecord::RecordNotUnique
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ module DjOne
|
|
31
31
|
job.unique_id = get_attribute(job, :perform_id)
|
32
32
|
job.save! if job.changed?
|
33
33
|
|
34
|
-
proceed.call
|
34
|
+
proceed.call(worker, job)
|
35
35
|
rescue ActiveRecord::RecordNotUnique
|
36
36
|
job.unique_id = job.unique_id_was
|
37
37
|
job.run_at = calculate_run_at(job)
|
@@ -40,7 +40,7 @@ module DjOne
|
|
40
40
|
|
41
41
|
def failure(worker, job, &proceed)
|
42
42
|
job.unique_id = nil
|
43
|
-
proceed.call
|
43
|
+
proceed.call(worker, job)
|
44
44
|
end
|
45
45
|
|
46
46
|
def get_attribute(job, method_name)
|
data/lib/dj_one/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dj_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Jakubowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|