delayed_job_mongoid 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +43 -19
- data/CONTRIBUTING.md +14 -14
- data/LICENSE.md +20 -20
- data/README.md +46 -36
- data/delayed_job_mongoid.gemspec +13 -18
- data/lib/delayed/backend/mongoid.rb +95 -77
- data/lib/delayed/serialization/mongoid.rb +25 -26
- data/lib/delayed/yaml/psych_ext.rb +14 -0
- data/lib/delayed/yaml/yaml_ext.rb +3 -0
- data/lib/delayed_job_mongoid.rb +6 -7
- metadata +12 -26
- data/Rakefile +0 -34
- data/lib/delayed/plugins.rb +0 -19
- data/spec/delayed_job_mongoid_spec.rb +0 -5
- data/spec/helper.rb +0 -42
- data/spec/plugins_spec.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1b064ab7ba80fe92ea75e98eed301b6d066e0b899d99dfe59a98a4a00183504b
|
4
|
+
data.tar.gz: bc12a94026c8fb0cae07a93a174678892bab73f91e670223c3c64b33bb6cd5d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 005b50b5063f7739679b785d7367c5cf80dc3f3d5315fdc97e55174d96ce17024c153e6e5f6ceaa6173c41dc10555af282358cd80938bfac427c6e7a45868c7f
|
7
|
+
data.tar.gz: 7ad70b9500041292afbdb4388f21509afb06d6197db866b0165c70927d236e16d1f4f4bb12bb42dab4c14eb79941cce464df77efe9ca8683a626f7d81cd017fa
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
*
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
*
|
19
|
-
*
|
1
|
+
### 3.0.1
|
2
|
+
|
3
|
+
* Your contribution here.
|
4
|
+
|
5
|
+
### 3.0.0
|
6
|
+
|
7
|
+
* [#81](https://github.com/collectiveidea/delayed_job_mongoid/pull/81): Drop support for Mongoid 3.0 and 4.0 - [johnnyshields](https://github.com/johnnyshields).
|
8
|
+
* [#82](https://github.com/collectiveidea/delayed_job_mongoid/pull/82): Correctly handle before_fork and after_fork hooks - [johnnyshields](https://github.com/johnnyshields).
|
9
|
+
* [#85](https://github.com/collectiveidea/delayed_job_mongoid/pull/85): Add additional indexes - [johnnyshields](https://github.com/johnnyshields).
|
10
|
+
* [#87](https://github.com/collectiveidea/delayed_job_mongoid/pull/87): Convert Travis CI to GH Actions - [johnnyshields](https://github.com/johnnyshields).
|
11
|
+
|
12
|
+
### 2.3.1 (2019/02/26)
|
13
|
+
|
14
|
+
* [#77](https://github.com/collectiveidea/delayed_job_mongoid/pull/77): Support Mongoid 7.0 - [Startouf](https://github.com/Startouf).
|
15
|
+
|
16
|
+
### 2.3.0 (2017/02/13)
|
17
|
+
|
18
|
+
* [#72](https://github.com/collectiveidea/delayed_job_mongoid/pull/72): Fix: Unknown alias: 1 (Psych::BadAlias) when referencing an object twice from the object being serialized - [@dblock](https://github.com/dblock), [@maxjacobson](https://github.com/maxjacobson).
|
19
|
+
* [#71](https://github.com/collectiveidea/delayed_job_mongoid/pull/71): Support Mongoid 6.0 - [@dblock](https://github.com/dblock).
|
20
|
+
|
21
|
+
### 2.2.0 (2015/09/24)
|
22
|
+
|
23
|
+
* [#58](https://github.com/collectiveidea/delayed_job_mongoid/pull/58): Support Mongoid 5.0 - [@sferik](https://github.com/sferik).
|
24
|
+
|
25
|
+
### 2.1.0 (2014/05/09)
|
26
|
+
|
27
|
+
* [#38](https://github.com/collectiveidea/delayed_job_mongoid/pull/38): Fix clearing identity map before each job - [@srleo](https://github.com/srleo).
|
28
|
+
* [#43](https://github.com/collectiveidea/delayed_job_mongoid/pull/43): Compatibility with Mongoid 4.x and Delayed Job 4.x - [@dblock](https://github.com/dblock).
|
29
|
+
|
30
|
+
### 2.0.0 (2012/08/02)
|
31
|
+
|
32
|
+
* Added code coverage with SimpleCov - [@sferik](https://github.com/sferik).
|
33
|
+
* Added Mongoid 3.0 support - [@sferik](https://github.com/sferik), [@asavartsov](https://github.com/asavartsov).
|
34
|
+
|
35
|
+
### 1.0.2 (2010/01/12)
|
36
|
+
|
37
|
+
* Fix a potential memory leak inside mongo when reserving jobs on mongo 1.6+
|
38
|
+
* Fixed gemspec to work with Mongoid 2.0 RC and Rubygems 1.4
|
39
|
+
|
40
|
+
### 1.0.1 (2010/12/01)
|
41
|
+
|
42
|
+
* Use MongoDB's findAndModify to reserve the next available job in one atomic operation - [@beljun](https://github.com/beljun).
|
43
|
+
* Better index
|
data/CONTRIBUTING.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
## How to contribute
|
2
|
-
|
3
|
-
If you find what looks like a bug:
|
4
|
-
|
5
|
-
* Search the [mailing list](http://groups.google.com/group/delayed_job) to see if anyone else had the same issue.
|
6
|
-
* Check the [GitHub issue tracker](http://github.com/collectiveidea/delayed_job_mongoid/issues/) to see if anyone else has reported issue.
|
7
|
-
* If you don't see anything, create an issue with information on how to reproduce it.
|
8
|
-
|
9
|
-
If you want to contribute an enhancement or a fix:
|
10
|
-
|
11
|
-
* Fork the project on github.
|
12
|
-
* Make your changes with tests.
|
13
|
-
* Commit the changes without making changes to the Rakefile or any other files that aren't related to your enhancement or fix
|
14
|
-
* Send a pull request.
|
1
|
+
## How to contribute
|
2
|
+
|
3
|
+
If you find what looks like a bug:
|
4
|
+
|
5
|
+
* Search the [mailing list](http://groups.google.com/group/delayed_job) to see if anyone else had the same issue.
|
6
|
+
* Check the [GitHub issue tracker](http://github.com/collectiveidea/delayed_job_mongoid/issues/) to see if anyone else has reported issue.
|
7
|
+
* If you don't see anything, create an issue with information on how to reproduce it.
|
8
|
+
|
9
|
+
If you want to contribute an enhancement or a fix:
|
10
|
+
|
11
|
+
* Fork the project on github.
|
12
|
+
* Make your changes with tests.
|
13
|
+
* Commit the changes without making changes to the Rakefile or any other files that aren't related to your enhancement or fix
|
14
|
+
* Send a pull request.
|
data/LICENSE.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright © 2010 Collective Idea
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright © 2010-2017 Collective Idea & Contributors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,36 +1,46 @@
|
|
1
|
-
# DelayedJob Mongoid backend
|
2
|
-
|
3
|
-
[![Gem Version]
|
4
|
-
[![Build Status]
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
To generate script/delayed_job
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
# DelayedJob Mongoid backend
|
2
|
+
|
3
|
+
[![Gem Version][gem-img]][gem-url]
|
4
|
+
[![Build Status][ghactions-img]][ghactions-url]
|
5
|
+
[![Code Climate][codeclimate-img]][codeclimate-url]
|
6
|
+
[![Coverage][coveralls-img]][coveralls-url]
|
7
|
+
|
8
|
+
## Requirements
|
9
|
+
|
10
|
+
Delayed Job Mongoid supports the following dependency versions:
|
11
|
+
|
12
|
+
- Ruby 2.3+
|
13
|
+
- Mongoid 5+
|
14
|
+
|
15
|
+
For Mongoid 3 and 4, use 2.x version of this gem.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add the gem to your Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'delayed_job_mongoid'
|
23
|
+
```
|
24
|
+
|
25
|
+
Then create the indexes (don't forget to do this in production):
|
26
|
+
|
27
|
+
```
|
28
|
+
script/rails runner 'Delayed::Backend::Mongoid::Job.create_indexes'
|
29
|
+
```
|
30
|
+
|
31
|
+
To generate `script/delayed_job`:
|
32
|
+
|
33
|
+
```
|
34
|
+
rails generate delayed_job
|
35
|
+
```
|
36
|
+
|
37
|
+
That's it. Use [delayed_job](http://github.com/collectiveidea/delayed_job) as normal.
|
38
|
+
|
39
|
+
[gem-img]: https://badge.fury.io/rb/delayed_job_mongoid.svg
|
40
|
+
[gem-url]: https://rubygems.org/gems/delayed_job_mongoid
|
41
|
+
[ghactions-img]: https://github.com/collectiveidea/delayed_job_mongoid/actions/workflows/test.yml/badge.svg?query=branch%3Amaster
|
42
|
+
[ghactions-url]: https://github.com/collectiveidea/delayed_job_mongoid/actions/workflows/test.yml?query=branch%3Amaster
|
43
|
+
[codeclimate-img]: https://codeclimate.com/github/collectiveidea/delayed_job_mongoid.svg
|
44
|
+
[codeclimate-url]: https://codeclimate.com/github/collectiveidea/delayed_job_mongoid
|
45
|
+
[coveralls-img]: https://coveralls.io/github/collectiveidea/delayed_job_mongoid/badge.svg?branch=master
|
46
|
+
[coveralls-url]: https://coveralls.io/github/collectiveidea/delayed_job_mongoid?branch=master
|
data/delayed_job_mongoid.gemspec
CHANGED
@@ -1,18 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
spec.
|
5
|
-
spec.
|
6
|
-
spec.
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
|
14
|
-
spec.require_paths = ['lib']
|
15
|
-
spec.summary = 'Mongoid backend for delayed_job'
|
16
|
-
spec.test_files = Dir.glob('spec/**/*')
|
17
|
-
spec.version = '2.1.0'
|
18
|
-
end
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.add_dependency 'delayed_job', ['>= 3.0', '< 5']
|
3
|
+
spec.add_dependency 'mongoid', '>= 5.0'
|
4
|
+
spec.authors = ['Chris Gaffney', 'Brandon Keepers', 'Erik Michaels-Ober']
|
5
|
+
spec.email = %w[chris@collectiveidea.com brandon@opensoul.com sferik@gmail.com]
|
6
|
+
spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md delayed_job_mongoid.gemspec] + Dir['lib/**/*.rb']
|
7
|
+
spec.homepage = 'http://github.com/collectiveidea/delayed_job_mongoid'
|
8
|
+
spec.licenses = ['MIT']
|
9
|
+
spec.name = 'delayed_job_mongoid'
|
10
|
+
spec.require_paths = ['lib']
|
11
|
+
spec.summary = 'Mongoid backend for delayed_job'
|
12
|
+
spec.version = '3.0.0'
|
13
|
+
end
|
@@ -1,77 +1,95 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
include ::Mongoid::
|
10
|
-
include ::
|
11
|
-
|
12
|
-
|
13
|
-
field :
|
14
|
-
field :
|
15
|
-
field :
|
16
|
-
field :
|
17
|
-
field :
|
18
|
-
field :
|
19
|
-
field :
|
20
|
-
field :
|
21
|
-
|
22
|
-
|
23
|
-
index :locked_by
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
1
|
+
require 'delayed_job'
|
2
|
+
require 'mongoid'
|
3
|
+
|
4
|
+
module Delayed
|
5
|
+
module Backend
|
6
|
+
module Mongoid
|
7
|
+
class Job
|
8
|
+
include ::Mongoid::Document
|
9
|
+
include ::Mongoid::Timestamps
|
10
|
+
include Delayed::Backend::Base
|
11
|
+
|
12
|
+
field :priority, type: Integer, default: 0
|
13
|
+
field :attempts, type: Integer, default: 0
|
14
|
+
field :handler, type: String
|
15
|
+
field :run_at, type: Time
|
16
|
+
field :locked_at, type: Time
|
17
|
+
field :locked_by, type: String
|
18
|
+
field :failed_at, type: Time
|
19
|
+
field :last_error, type: String
|
20
|
+
field :queue, type: String
|
21
|
+
|
22
|
+
index locked_by: -1, priority: 1, run_at: 1
|
23
|
+
index queue: 1, locked_by: -1, priority: 1, run_at: 1
|
24
|
+
index failed_at: 1, locked_by: -1, priority: 1, run_at: 1
|
25
|
+
index failed_at: 1, queue: 1, locked_by: -1, priority: 1, run_at: 1
|
26
|
+
|
27
|
+
before_save :set_default_run_at
|
28
|
+
|
29
|
+
def reload(*args)
|
30
|
+
reset
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def db_time_now
|
36
|
+
Time.now.utc
|
37
|
+
end
|
38
|
+
|
39
|
+
# Reserves one job for the worker.
|
40
|
+
# Atomically picks and locks one job from the collection.
|
41
|
+
def reserve(worker, max_run_time = Worker.max_run_time)
|
42
|
+
right_now = db_time_now
|
43
|
+
criteria = reservation_criteria(worker, right_now, max_run_time)
|
44
|
+
criteria.find_one_and_update(
|
45
|
+
{ '$set' => { locked_at: right_now, locked_by: worker.name } },
|
46
|
+
return_document: :after
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# When a worker is exiting, make sure we don't have any locked jobs.
|
51
|
+
def clear_locks!(worker_name)
|
52
|
+
where(locked_by: worker_name).update_all(locked_at: nil, locked_by: nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
# In a multi-process setup, this will be called at boot time
|
56
|
+
# to close unnecessary database connections on the parent process.
|
57
|
+
def before_fork
|
58
|
+
::Mongoid.disconnect_clients
|
59
|
+
end
|
60
|
+
|
61
|
+
# In a multi-process setup, this will be called to ensure fresh
|
62
|
+
# database connections are immediately made on each newly spawned child process.
|
63
|
+
def after_fork
|
64
|
+
::Mongoid::Clients.clients.each do |_name, client|
|
65
|
+
client.close
|
66
|
+
client.reconnect
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
# Mongo criteria matching all the jobs the worker can reserve.
|
73
|
+
# Jobs are sorted by priority and run_at.
|
74
|
+
def reservation_criteria(worker, right_now, max_run_time)
|
75
|
+
criteria = where(
|
76
|
+
run_at: { '$lte' => right_now },
|
77
|
+
failed_at: nil
|
78
|
+
).any_of(
|
79
|
+
{ locked_by: worker.name },
|
80
|
+
{ locked_at: nil },
|
81
|
+
locked_at: { '$lt' => (right_now - max_run_time) }
|
82
|
+
)
|
83
|
+
|
84
|
+
criteria = criteria.gte(priority: Worker.min_priority.to_i) if Worker.min_priority
|
85
|
+
criteria = criteria.lte(priority: Worker.max_priority.to_i) if Worker.max_priority
|
86
|
+
criteria = criteria.any_in(queue: Worker.queues) if Worker.queues.any?
|
87
|
+
criteria = criteria.desc(:locked_by).asc(:priority).asc(:run_at)
|
88
|
+
|
89
|
+
criteria
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -1,26 +1,25 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
coder['
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
1
|
+
require 'delayed_job'
|
2
|
+
require 'mongoid'
|
3
|
+
|
4
|
+
if YAML.parser.class.name =~ /syck/i
|
5
|
+
Mongoid::Document.class_eval do
|
6
|
+
yaml_as 'tag:ruby.yaml.org,2002:Mongoid'
|
7
|
+
|
8
|
+
def self.yaml_new(klass, _, val)
|
9
|
+
klass.find(val['attributes']['_id'])
|
10
|
+
rescue Mongoid::Errors::DocumentNotFound
|
11
|
+
raise Delayed::DeserializationError
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_yaml_properties
|
15
|
+
['@attributes']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
Mongoid::Document.class_eval do
|
20
|
+
def encode_with(coder)
|
21
|
+
coder['attributes'] = @attributes
|
22
|
+
coder.tag = ['!ruby/Mongoid', self.class.name].join(':')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Delayed
|
2
|
+
module PsychExt
|
3
|
+
class ToRuby < Psych::Visitors::ToRuby
|
4
|
+
# see https://github.com/collectiveidea/delayed_job_mongoid/pull/65
|
5
|
+
alias _visit_Psych_Nodes_Mapping visit_Psych_Nodes_Mapping
|
6
|
+
|
7
|
+
def visit_Psych_Nodes_Mapping(object) # rubocop:disable MethodName
|
8
|
+
document = _visit_Psych_Nodes_Mapping(object)
|
9
|
+
register(object, document) if document
|
10
|
+
document
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/delayed_job_mongoid.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
require 'delayed/
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
Delayed::Worker.backend = :mongoid
|
1
|
+
require 'delayed/backend/mongoid'
|
2
|
+
require 'delayed/serialization/mongoid'
|
3
|
+
require 'delayed_job'
|
4
|
+
require 'delayed/yaml/yaml_ext'
|
5
|
+
|
6
|
+
Delayed::Worker.backend = :mongoid
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Gaffney
|
8
8
|
- Brandon Keepers
|
9
9
|
- Erik Michaels-Ober
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: delayed_job
|
@@ -38,21 +38,15 @@ dependencies:
|
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
42
|
-
- - "<"
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '5'
|
41
|
+
version: '5.0'
|
45
42
|
type: :runtime
|
46
43
|
prerelease: false
|
47
44
|
version_requirements: !ruby/object:Gem::Requirement
|
48
45
|
requirements:
|
49
46
|
- - ">="
|
50
47
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
52
|
-
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5'
|
55
|
-
description:
|
48
|
+
version: '5.0'
|
49
|
+
description:
|
56
50
|
email:
|
57
51
|
- chris@collectiveidea.com
|
58
52
|
- brandon@opensoul.com
|
@@ -65,20 +59,17 @@ files:
|
|
65
59
|
- CONTRIBUTING.md
|
66
60
|
- LICENSE.md
|
67
61
|
- README.md
|
68
|
-
- Rakefile
|
69
62
|
- delayed_job_mongoid.gemspec
|
70
63
|
- lib/delayed/backend/mongoid.rb
|
71
|
-
- lib/delayed/plugins.rb
|
72
64
|
- lib/delayed/serialization/mongoid.rb
|
65
|
+
- lib/delayed/yaml/psych_ext.rb
|
66
|
+
- lib/delayed/yaml/yaml_ext.rb
|
73
67
|
- lib/delayed_job_mongoid.rb
|
74
|
-
- spec/delayed_job_mongoid_spec.rb
|
75
|
-
- spec/helper.rb
|
76
|
-
- spec/plugins_spec.rb
|
77
68
|
homepage: http://github.com/collectiveidea/delayed_job_mongoid
|
78
69
|
licenses:
|
79
70
|
- MIT
|
80
71
|
metadata: {}
|
81
|
-
post_install_message:
|
72
|
+
post_install_message:
|
82
73
|
rdoc_options: []
|
83
74
|
require_paths:
|
84
75
|
- lib
|
@@ -93,13 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
84
|
- !ruby/object:Gem::Version
|
94
85
|
version: '0'
|
95
86
|
requirements: []
|
96
|
-
|
97
|
-
|
98
|
-
signing_key:
|
87
|
+
rubygems_version: 3.1.2
|
88
|
+
signing_key:
|
99
89
|
specification_version: 4
|
100
90
|
summary: Mongoid backend for delayed_job
|
101
|
-
test_files:
|
102
|
-
- spec/delayed_job_mongoid_spec.rb
|
103
|
-
- spec/helper.rb
|
104
|
-
- spec/plugins_spec.rb
|
105
|
-
has_rdoc:
|
91
|
+
test_files: []
|
data/Rakefile
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler/setup'
|
4
|
-
Bundler::GemHelper.install_tasks
|
5
|
-
|
6
|
-
require 'rspec/core/rake_task'
|
7
|
-
desc 'Run the specs'
|
8
|
-
RSpec::Core::RakeTask.new do |r|
|
9
|
-
r.verbose = false
|
10
|
-
end
|
11
|
-
|
12
|
-
task :test => :spec
|
13
|
-
|
14
|
-
begin
|
15
|
-
require 'rubocop/rake_task'
|
16
|
-
Rubocop::RakeTask.new
|
17
|
-
rescue LoadError
|
18
|
-
task :rubocop do
|
19
|
-
$stderr.puts 'Rubocop is disabled'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
require 'yardstick/rake/measurement'
|
24
|
-
Yardstick::Rake::Measurement.new do |measurement|
|
25
|
-
measurement.output = 'measurement/report.txt'
|
26
|
-
end
|
27
|
-
|
28
|
-
require 'yardstick/rake/verify'
|
29
|
-
Yardstick::Rake::Verify.new do |verify|
|
30
|
-
verify.require_exact_threshold = false
|
31
|
-
verify.threshold = 53.3
|
32
|
-
end
|
33
|
-
|
34
|
-
task :default => [:spec, :rubocop, :verify_measurements]
|
data/lib/delayed/plugins.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# clear Mongoid::IdentityMap before each job
|
3
|
-
#
|
4
|
-
|
5
|
-
if Delayed::Backend::Mongoid.mongoid3?
|
6
|
-
module Delayed
|
7
|
-
module Plugins
|
8
|
-
class ClearIdentityMap < Plugin
|
9
|
-
callbacks do |lifecycle|
|
10
|
-
lifecycle.before(:invoke_job) do
|
11
|
-
Mongoid::IdentityMap.clear
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Delayed::Worker.plugins << Delayed::Plugins::ClearIdentityMap
|
19
|
-
end
|
data/spec/helper.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter '/spec/'
|
11
|
-
minimum_coverage(77.27)
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'rspec'
|
15
|
-
require 'delayed_job_mongoid'
|
16
|
-
require 'delayed/backend/shared_spec'
|
17
|
-
|
18
|
-
RSpec.configure do |config|
|
19
|
-
config.expect_with :rspec do |c|
|
20
|
-
c.syntax = :expect
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Mongoid.configure do |config|
|
25
|
-
config.connect_to('dl_spec')
|
26
|
-
end
|
27
|
-
|
28
|
-
class Story
|
29
|
-
include ::Mongoid::Document
|
30
|
-
field :text
|
31
|
-
|
32
|
-
def tell
|
33
|
-
text
|
34
|
-
end
|
35
|
-
|
36
|
-
def whatever(n, _)
|
37
|
-
tell * n
|
38
|
-
end
|
39
|
-
def self.count; end
|
40
|
-
|
41
|
-
handle_asynchronously :whatever
|
42
|
-
end
|
data/spec/plugins_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
if Delayed::Backend::Mongoid.mongoid3?
|
4
|
-
describe Delayed::Backend::Mongoid::Job do
|
5
|
-
let(:worker) { Delayed::Worker.new }
|
6
|
-
before do
|
7
|
-
Delayed::Worker.max_priority = nil
|
8
|
-
Delayed::Worker.min_priority = nil
|
9
|
-
Delayed::Worker.default_priority = 99
|
10
|
-
Delayed::Worker.delay_jobs = true
|
11
|
-
SimpleJob.runs = 0
|
12
|
-
described_class.delete_all
|
13
|
-
end
|
14
|
-
after do
|
15
|
-
Delayed::Worker.reset
|
16
|
-
end
|
17
|
-
it 'clears mongoid identity map' do
|
18
|
-
expect(Mongoid::IdentityMap).to receive(:clear).once
|
19
|
-
described_class.enqueue SimpleJob.new, :priority => 5
|
20
|
-
worker.work_off
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|