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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 824ab3dc83ed1613e9e2ece9ed703a411aba94d3
4
- data.tar.gz: 6a286aae4db6c1efbce2fe0449f88fc652ef6f03
2
+ SHA256:
3
+ metadata.gz: 1b064ab7ba80fe92ea75e98eed301b6d066e0b899d99dfe59a98a4a00183504b
4
+ data.tar.gz: bc12a94026c8fb0cae07a93a174678892bab73f91e670223c3c64b33bb6cd5d5
5
5
  SHA512:
6
- metadata.gz: 8134c2be8e5a26297c7c1713791357ce47bbf3d510362748f6726e122addd90dda2f5619c842dca2c66e7100a4879f0c0924ea0eb9af3796d0905f605df57b65
7
- data.tar.gz: 68ef96228c0e632607e623208d0be3b4cbcc090e9107b080ee1a635ef62dc21f38d8b3604ce705db0efdf2278bc22cc5973e3d4113a385102a216883d1a59912
6
+ metadata.gz: 005b50b5063f7739679b785d7367c5cf80dc3f3d5315fdc97e55174d96ce17024c153e6e5f6ceaa6173c41dc10555af282358cd80938bfac427c6e7a45868c7f
7
+ data.tar.gz: 7ad70b9500041292afbdb4388f21509afb06d6197db866b0165c70927d236e16d1f4f4bb12bb42dab4c14eb79941cce464df77efe9ca8683a626f7d81cd017fa
data/CHANGELOG.md CHANGED
@@ -1,19 +1,43 @@
1
- Next Release
2
- ============
3
- * [#38](https://github.com/collectiveidea/delayed_job_mongoid/pull/38): Fix clearing identity map before each job - [@srleo](https://github.com/srleo)
4
- * [#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)
5
-
6
- 2.0.0
7
- =====
8
- * Added code coverage with SimpleCov - [@sferik](https://github.com/sferik)
9
- * Added Mongoid 3.0 support - [@sferik](https://github.com/sferik), [@asavartsov](https://github.com/asavartsov)
10
-
11
- 1.0.2 - 2010-01-12
12
- ==================
13
- * Fix a potential memory leak inside mongo when reserving jobs on mongo 1.6+
14
- * Fixed gemspec to work with Mongoid 2.0 RC and Rubygems 1.4
15
-
16
- 1.0.1 - 2010-12-01
17
- ==================
18
- * Use MongoDB's findAndModify to reserve the next available job in one atomic operation
19
- * 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 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](http://img.shields.io/gem/v/delayed_job_mongoid.svg)][gem]
4
- [![Build Status](http://img.shields.io/travis/collectiveidea/delayed_job_mongoid.svg)][travis]
5
- [![Dependency Status](http://img.shields.io/gemnasium/collectiveidea/delayed_job_mongoid.svg)][gemnasium]
6
- [![Code Climate](http://img.shields.io/codeclimate/github/collectiveidea/delayed_job_mongoid.svg)][codeclimate]
7
- [![Coverage Status](http://img.shields.io/coveralls/collectiveidea/delayed_job_mongoid.svg)][coveralls]
8
-
9
- [gem]: https://rubygems.org/gems/delayed_job_mongoid
10
- [travis]: http://travis-ci.org/collectiveidea/delayed_job_mongoid
11
- [gemnasium]: https://gemnasium.com/collectiveidea/delayed_job_mongoid
12
- [codeclimate]: https://codeclimate.com/github/collectiveidea/delayed_job_mongoid
13
- [coveralls]: https://coveralls.io/r/collectiveidea/delayed_job_mongoid
14
-
15
- ## Requirements
16
-
17
- Make sure you are using MongoDB version 1.3 or newer. `delayed_job_mongoid`
18
- uses the `findandmodify` command which is only available in recent versions.
19
-
20
- ## Installation
21
-
22
- Add the gem to your Gemfile:
23
-
24
- gem 'delayed_job_mongoid'
25
-
26
- After running `bundle install`, create the indexes (and don't forget to do this
27
- on your production database):
28
-
29
- script/rails runner 'Delayed::Backend::Mongoid::Job.create_indexes'
30
-
31
- To generate script/delayed_job:
32
-
33
- rails generate delayed_job
34
-
35
- That's it. Use [delayed_job](http://github.com/collectiveidea/delayed_job) as
36
- 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,18 +1,13 @@
1
- # encoding: utf-8
2
-
3
- Gem::Specification.new do |spec|
4
- spec.add_dependency 'delayed_job', ['>= 3.0', '< 5']
5
- spec.add_dependency 'mongoid', ['>= 3.0', '< 5']
6
- spec.authors = ['Chris Gaffney', 'Brandon Keepers', 'Erik Michaels-Ober']
7
- spec.email = ['chris@collectiveidea.com', 'brandon@opensoul.com', 'sferik@gmail.com']
8
- spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile delayed_job_mongoid.gemspec]
9
- spec.files += Dir.glob('lib/**/*.rb')
10
- spec.files += Dir.glob('spec/**/*')
11
- spec.homepage = 'http://github.com/collectiveidea/delayed_job_mongoid'
12
- spec.licenses = ['MIT']
13
- spec.name = 'delayed_job_mongoid'
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
- # encoding: utf-8
2
- require 'delayed_job'
3
- require 'mongoid'
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 this job for the worker.
32
- #
33
- # Uses Mongo's findAndModify operation to atomically pick and lock one
34
- # job from from the collection.
35
- def self.reserve(worker, max_run_time = Worker.max_run_time)
36
- right_now = db_time_now
37
-
38
- criteria = where(
39
- :run_at => {'$lte' => right_now},
40
- :failed_at => nil
41
- ).any_of(
42
- {:locked_by => worker.name},
43
- {:locked_at => nil},
44
- {:locked_at => {'$lt' => (right_now - max_run_time)}}
45
- )
46
-
47
- criteria = criteria.gte(:priority => Worker.min_priority.to_i) if Worker.min_priority
48
- criteria = criteria.lte(:priority => Worker.max_priority.to_i) if Worker.max_priority
49
- criteria = criteria.any_in(:queue => Worker.queues) if Worker.queues.any?
50
-
51
- criteria.desc(:locked_by).asc(:priority).asc(:run_at).find_and_modify(
52
- {'$set' => {:locked_at => right_now, :locked_by => worker.name}}, :new => true
53
- )
54
- end
55
-
56
- # When a worker is exiting, make sure we don't have any locked jobs.
57
- def self.clear_locks!(worker_name)
58
- where(:locked_by => worker_name).update_all(:locked_at => nil, :locked_by => nil)
59
- end
60
-
61
- def reload(*args)
62
- reset
63
- super
64
- end
65
-
66
- # Hook method that is called after a new worker is forked
67
- def self.after_fork
68
- # to avoid `failed with error "unauthorized"` errors in Mongoid 4.0.alpha2
69
- ::Mongoid.default_session.disconnect
70
- end
71
- end
72
- def self.mongoid3?
73
- ::Mongoid.const_defined? :Observer # deprecated in Mongoid 4.x
74
- end
75
- end
76
- end
77
- 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,26 +1,25 @@
1
- # encoding: utf-8
2
- require 'delayed_job'
3
- require 'mongoid'
4
-
5
- if YAML.parser.class.name =~ /syck/i
6
- Mongoid::Document.class_eval do
7
- yaml_as 'tag:ruby.yaml.org,2002:Mongoid'
8
-
9
- def self.yaml_new(klass, _, val)
10
- klass.find(val['attributes']['_id'])
11
- rescue Mongoid::Errors::DocumentNotFound
12
- raise Delayed::DeserializationError
13
- end
14
-
15
- def to_yaml_properties
16
- ['@attributes']
17
- end
18
- end
19
- else
20
- Mongoid::Document.class_eval do
21
- def encode_with(coder)
22
- coder['attributes'] = @attributes
23
- coder.tag = ['!ruby/Mongoid', self.class.name].join(':')
24
- end
25
- end
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
@@ -0,0 +1,3 @@
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
- # encoding: utf-8
2
- require 'delayed/backend/mongoid'
3
- require 'delayed/serialization/mongoid'
4
- require 'delayed_job'
5
- require 'delayed/plugins'
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: 2.1.0
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: 2014-05-09 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
16
  name: delayed_job
@@ -38,21 +38,15 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '3.0'
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: '3.0'
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
- rubyforge_project:
97
- rubygems_version: 2.2.2
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]
@@ -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
@@ -1,5 +0,0 @@
1
- require 'helper'
2
-
3
- describe Delayed::Backend::Mongoid::Job do
4
- it_behaves_like 'a delayed_job backend'
5
- 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