delayed_job_mongoid 2.3.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6828c0132cd80f7eccb1f7acb686f5ef3d16254fa08ed4cb9ccb2f2db59ba349
4
- data.tar.gz: e0d29f859a576888838447b5f6da17c7f71fda605fcd16c9ff8e0ba1c2018342
3
+ metadata.gz: 1b064ab7ba80fe92ea75e98eed301b6d066e0b899d99dfe59a98a4a00183504b
4
+ data.tar.gz: bc12a94026c8fb0cae07a93a174678892bab73f91e670223c3c64b33bb6cd5d5
5
5
  SHA512:
6
- metadata.gz: '0444914059ccf2ae3d96dd0cd42cdfb53ff63370a54d96ef2fb874948ea9db9c392551a58acbb8530d6287779934b32662cb69c7c3d4df7243427fd83706001d'
7
- data.tar.gz: 7449a2effb06c3a516e6346b81809362a02158b87016d52ac33ce4da27955b2da2c18d8cb50b92872036c5a16de9b61fb8ad4bd9ae4b77c7c90901574a34a907
6
+ metadata.gz: 005b50b5063f7739679b785d7367c5cf80dc3f3d5315fdc97e55174d96ce17024c153e6e5f6ceaa6173c41dc10555af282358cd80938bfac427c6e7a45868c7f
7
+ data.tar.gz: 7ad70b9500041292afbdb4388f21509afb06d6197db866b0165c70927d236e16d1f4f4bb12bb42dab4c14eb79941cce464df77efe9ca8683a626f7d81cd017fa
data/CHANGELOG.md CHANGED
@@ -1,32 +1,43 @@
1
- ### 2.3.1 (2019/02/26)
2
-
3
- * [#77](https://github.com/collectiveidea/delayed_job_mongoid/pull/77): Support Mongoid 7.0 - [Startouf](https://github.com/Startouf).
4
-
5
- ### 2.3.0 (2017/02/13)
6
-
7
- * [#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).
8
- * [#71](https://github.com/collectiveidea/delayed_job_mongoid/pull/71): Support Mongoid 6.0 - [@dblock](https://github.com/dblock).
9
-
10
- ### 2.2.0 (2015/09/24)
11
-
12
- * [#58](https://github.com/collectiveidea/delayed_job_mongoid/pull/58): Support Mongoid 5.0 - [@sferik](https://github.com/sferik).
13
-
14
- ### 2.1.0 (2014/05/09)
15
-
16
- * [#38](https://github.com/collectiveidea/delayed_job_mongoid/pull/38): Fix clearing identity map before each job - [@srleo](https://github.com/srleo).
17
- * [#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).
18
-
19
- ### 2.0.0 (2012/08/02)
20
-
21
- * Added code coverage with SimpleCov - [@sferik](https://github.com/sferik).
22
- * Added Mongoid 3.0 support - [@sferik](https://github.com/sferik), [@asavartsov](https://github.com/asavartsov).
23
-
24
- ### 1.0.2 (2010/01/12)
25
-
26
- * Fix a potential memory leak inside mongo when reserving jobs on mongo 1.6+
27
- * Fixed gemspec to work with Mongoid 2.0 RC and Rubygems 1.4
28
-
29
- ### 1.0.1 (2010/12/01)
30
-
31
- * Use MongoDB's findAndModify to reserve the next available job in one atomic operation - [@beljun](https://github.com/beljun).
32
- * Better index
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-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.
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,32 +1,46 @@
1
- # DelayedJob Mongoid backend
2
-
3
- [![Gem Version](https://badge.fury.io/rb/delayed_job_mongoid.svg)](http://badge.fury.io/rb/delayed_job_mongoid)
4
- [![Build Status](https://travis-ci.org/collectiveidea/delayed_job_mongoid.svg?branch=master)](https://travis-ci.org/collectiveidea/delayed_job_mongoid)
5
- [![Code Climate](https://codeclimate.com/github/collectiveidea/delayed_job_mongoid.svg)](https://codeclimate.com/github/collectiveidea/delayed_job_mongoid)
6
- [![Coverage Status](https://coveralls.io/repos/collectiveidea/delayed_job_mongoid/badge.svg?branch=master&service=github)](https://coveralls.io/github/collectiveidea/delayed_job_mongoid?branch=master)
7
-
8
- [gem]: https://rubygems.org/gems/delayed_job_mongoid
9
- [travis]: http://travis-ci.org/collectiveidea/delayed_job_mongoid
10
- [codeclimate]: https://codeclimate.com/github/collectiveidea/delayed_job_mongoid
11
- [coveralls]: https://coveralls.io/r/collectiveidea/delayed_job_mongoid
12
-
13
- ## Requirements
14
-
15
- Mongoid 3, 4, 5, 6 or 7.
16
-
17
- ## Installation
18
-
19
- Add the gem to your Gemfile:
20
-
21
- gem 'delayed_job_mongoid'
22
-
23
- Create the indexes (and don't forget to do this on your production database):
24
-
25
- script/rails runner 'Delayed::Backend::Mongoid::Job.create_indexes'
26
-
27
- To generate `script/delayed_job`:
28
-
29
- rails generate delayed_job
30
-
31
- That's it. Use [delayed_job](http://github.com/collectiveidea/delayed_job) as
32
- normal.
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
@@ -1,14 +1,13 @@
1
- Gem::Specification.new do |spec|
2
- spec.add_dependency 'delayed_job', ['>= 3.0', '< 5']
3
- spec.add_dependency 'mongoid', ['>= 3.0', '< 8']
4
- spec.add_dependency 'mongoid-compatibility', '>= 0.4.0'
5
- spec.authors = ['Chris Gaffney', 'Brandon Keepers', 'Erik Michaels-Ober']
6
- spec.email = ['chris@collectiveidea.com', 'brandon@opensoul.com', 'sferik@gmail.com']
7
- spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md delayed_job_mongoid.gemspec] + Dir['lib/**/*.rb']
8
- spec.homepage = 'http://github.com/collectiveidea/delayed_job_mongoid'
9
- spec.licenses = ['MIT']
10
- spec.name = 'delayed_job_mongoid'
11
- spec.require_paths = ['lib']
12
- spec.summary = 'Mongoid backend for delayed_job'
13
- spec.version = '2.3.1'
14
- 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,95 +1,95 @@
1
- require 'delayed_job'
2
- require 'mongoid'
3
- require 'mongoid/compatibility'
4
-
5
- module Delayed
6
- module Backend
7
- module Mongoid
8
- class Job
9
- include ::Mongoid::Document
10
- include ::Mongoid::Timestamps
11
- include Delayed::Backend::Base
12
-
13
- field :priority, type: Integer, default: 0
14
- field :attempts, type: Integer, default: 0
15
- field :handler, type: String
16
- field :run_at, type: Time
17
- field :locked_at, type: Time
18
- field :locked_by, type: String
19
- field :failed_at, type: Time
20
- field :last_error, type: String
21
- field :queue, type: String
22
-
23
- index locked_by: -1, priority: 1, run_at: 1
24
-
25
- before_save :set_default_run_at
26
-
27
- def self.db_time_now
28
- Time.now.utc
29
- end
30
-
31
- # Reserves one job for the worker.
32
- #
33
- # Atomically picks and locks one job from the collection.
34
- def self.reserve(worker, max_run_time = Worker.max_run_time)
35
- right_now = db_time_now
36
-
37
- criteria = reservation_criteria worker, right_now, max_run_time
38
-
39
- if ::Mongoid::Compatibility::Version.mongoid2? || ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4?
40
- criteria.find_and_modify(
41
- { '$set' => { locked_at: right_now, locked_by: worker.name } },
42
- new: true
43
- )
44
- else
45
- criteria.find_one_and_update(
46
- { '$set' => { locked_at: right_now, locked_by: worker.name } },
47
- return_document: :after
48
- )
49
- end
50
- end
51
-
52
- # Mongo criteria matching all the jobs the worker can reserver
53
- #
54
- # Jobs are sorted by priority and run_at.
55
- #
56
- # @api private
57
- def self.reservation_criteria(worker, right_now, max_run_time)
58
- criteria = where(
59
- run_at: { '$lte' => right_now },
60
- failed_at: nil
61
- ).any_of(
62
- { locked_by: worker.name },
63
- { locked_at: nil },
64
- locked_at: { '$lt' => (right_now - max_run_time) }
65
- )
66
-
67
- criteria = criteria.gte(priority: Worker.min_priority.to_i) if Worker.min_priority
68
- criteria = criteria.lte(priority: Worker.max_priority.to_i) if Worker.max_priority
69
- criteria = criteria.any_in(queue: Worker.queues) if Worker.queues.any?
70
- criteria = criteria.desc(:locked_by).asc(:priority).asc(:run_at)
71
-
72
- criteria
73
- end
74
-
75
- # When a worker is exiting, make sure we don't have any locked jobs.
76
- def self.clear_locks!(worker_name)
77
- where(locked_by: worker_name).update_all(locked_at: nil, locked_by: nil)
78
- end
79
-
80
- def reload(*args)
81
- reset
82
- super
83
- end
84
-
85
- # Hook method that is called after a new worker is forked
86
- def self.after_fork
87
- if ::Mongoid::Compatibility::Version.mongoid4?
88
- # to avoid `failed with error "unauthorized"` errors in Mongoid 4.0.alpha2
89
- ::Mongoid.default_session.disconnect
90
- end
91
- end
92
- end
93
- end
94
- end
95
- end
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,25 +1,25 @@
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
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
@@ -1,14 +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
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
@@ -1,3 +1,3 @@
1
- require 'yaml'
2
-
3
- require File.expand_path('psych_ext', __dir__) unless YAML.parser.class.name =~ /syck|yecht/i
1
+ require 'yaml'
2
+
3
+ require File.expand_path('psych_ext', __dir__) unless YAML.parser.class.name =~ /syck|yecht/i
@@ -1,7 +1,6 @@
1
- require 'delayed/backend/mongoid'
2
- require 'delayed/serialization/mongoid'
3
- require 'delayed_job'
4
- require 'delayed/plugins'
5
- require 'delayed/yaml/yaml_ext'
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Gaffney
@@ -10,9 +10,10 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-02-27 00:00:00.000000000 Z
13
+ date: 2021-09-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
+ name: delayed_job
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
19
  - - ">="
@@ -21,9 +22,8 @@ dependencies:
21
22
  - - "<"
22
23
  - !ruby/object:Gem::Version
23
24
  version: '5'
24
- name: delayed_job
25
- prerelease: false
26
25
  type: :runtime
26
+ prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
@@ -33,39 +33,19 @@ dependencies:
33
33
  - !ruby/object:Gem::Version
34
34
  version: '5'
35
35
  - !ruby/object:Gem::Dependency
36
- requirement: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '3.0'
41
- - - "<"
42
- - !ruby/object:Gem::Version
43
- version: '8'
44
36
  name: mongoid
45
- prerelease: false
46
- type: :runtime
47
- version_requirements: !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: '3.0'
52
- - - "<"
53
- - !ruby/object:Gem::Version
54
- version: '8'
55
- - !ruby/object:Gem::Dependency
56
37
  requirement: !ruby/object:Gem::Requirement
57
38
  requirements:
58
39
  - - ">="
59
40
  - !ruby/object:Gem::Version
60
- version: 0.4.0
61
- name: mongoid-compatibility
62
- prerelease: false
41
+ version: '5.0'
63
42
  type: :runtime
43
+ prerelease: false
64
44
  version_requirements: !ruby/object:Gem::Requirement
65
45
  requirements:
66
46
  - - ">="
67
47
  - !ruby/object:Gem::Version
68
- version: 0.4.0
48
+ version: '5.0'
69
49
  description:
70
50
  email:
71
51
  - chris@collectiveidea.com
@@ -81,7 +61,6 @@ files:
81
61
  - README.md
82
62
  - delayed_job_mongoid.gemspec
83
63
  - lib/delayed/backend/mongoid.rb
84
- - lib/delayed/plugins.rb
85
64
  - lib/delayed/serialization/mongoid.rb
86
65
  - lib/delayed/yaml/psych_ext.rb
87
66
  - lib/delayed/yaml/yaml_ext.rb
@@ -105,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
84
  - !ruby/object:Gem::Version
106
85
  version: '0'
107
86
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 2.7.6
87
+ rubygems_version: 3.1.2
110
88
  signing_key:
111
89
  specification_version: 4
112
90
  summary: Mongoid backend for delayed_job
@@ -1,19 +0,0 @@
1
- #
2
- # clear Mongoid::IdentityMap before each job
3
- #
4
-
5
- if ::Mongoid::Compatibility::Version.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