Skip to content

Commit

Permalink
Merge fce5b3e into d915199
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Apr 1, 2021
2 parents d915199 + fce5b3e commit dfada8d
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 97 deletions.
15 changes: 1 addition & 14 deletions .travis.yml
Expand Up @@ -6,7 +6,7 @@ sudo: false

matrix:
include:
- rvm: 2.5.3
- rvm: 2.6.6
env:
- MONGOID_VERSION=7
- rvm: 2.3.1
Expand All @@ -15,12 +15,6 @@ matrix:
- rvm: 2.3.1
env:
- MONGOID_VERSION=5
- rvm: 2.2
env:
- MONGOID_VERSION=4
- rvm: 2.5.3
env:
- MONGOID_VERSION=3
- rvm: jruby-head
- rvm: rbx-2
- rvm: ruby-head
Expand All @@ -30,10 +24,3 @@ matrix:
- rvm: ruby-head

services: mongodb

addons:
apt:
sources:
- mongodb-3.2-precise
packages:
- mongodb-org-server
7 changes: 6 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,12 @@
### 2.3.2 (Next)
### 3.0.1 (Next)

* Your contribution here.

### 3.0.0 (2019/02/26)

* [#81](https://github.com/collectiveidea/delayed_job_mongoid/pull/81): Drop support for Mongoid 3.0 and 4.0 - [johnnyshields](https://github.com/johnnyshields).
* [#81](https://github.com/collectiveidea/delayed_job_mongoid/pull/81): Perform disconnect on after_fork on all Mongoid versions - [johnnyshields](https://github.com/johnnyshields).

### 2.3.1 (2019/02/26)

* [#77](https://github.com/collectiveidea/delayed_job_mongoid/pull/77): Support Mongoid 7.0 - [Startouf](https://github.com/Startouf).
Expand Down
4 changes: 0 additions & 4 deletions Gemfile
Expand Up @@ -20,10 +20,6 @@ when /^6/
gem 'mongoid', '~> 6.0'
when /^5/
gem 'mongoid', '~> 5.0'
when /^4/
gem 'mongoid', '~> 4.0'
when /^3/
gem 'mongoid', '~> 3.1'
else
gem 'mongoid', version
end
Expand Down
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -12,7 +12,9 @@

## Requirements

Mongoid 3, 4, 5, 6 or 7.
Mongoid 5 or later.

(For Mongoid 3 and 4, use 2.x version of this gem)

## Installation

Expand All @@ -28,5 +30,4 @@ To generate `script/delayed_job`:

rails generate delayed_job

That's it. Use [delayed_job](http://github.com/collectiveidea/delayed_job) as
normal.
That's it. Use [delayed_job](http://github.com/collectiveidea/delayed_job) as normal.
21 changes: 10 additions & 11 deletions delayed_job_mongoid.gemspec
@@ -1,14 +1,13 @@
Gem::Specification.new do |spec|
spec.add_dependency 'delayed_job', ['>= 3.0', '< 5']
spec.add_dependency 'mongoid', ['>= 3.0', '< 8']
spec.add_dependency 'mongoid-compatibility', '>= 0.4.0'
spec.authors = ['Chris Gaffney', 'Brandon Keepers', 'Erik Michaels-Ober']
spec.email = ['chris@collectiveidea.com', 'brandon@opensoul.com', 'sferik@gmail.com']
spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md delayed_job_mongoid.gemspec] + Dir['lib/**/*.rb']
spec.homepage = 'http://github.com/collectiveidea/delayed_job_mongoid'
spec.licenses = ['MIT']
spec.name = 'delayed_job_mongoid'
spec.require_paths = ['lib']
spec.summary = 'Mongoid backend for delayed_job'
spec.version = '2.3.2'
spec.add_dependency 'mongoid', '>= 5.0'
spec.authors = ['Chris Gaffney', 'Brandon Keepers', 'Erik Michaels-Ober']
spec.email = ['chris@collectiveidea.com', 'brandon@opensoul.com', 'sferik@gmail.com']
spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md delayed_job_mongoid.gemspec] + Dir['lib/**/*.rb']
spec.homepage = 'http://github.com/collectiveidea/delayed_job_mongoid'
spec.licenses = ['MIT']
spec.name = 'delayed_job_mongoid'
spec.require_paths = ['lib']
spec.summary = 'Mongoid backend for delayed_job'
spec.version = '3.0.0'
end
25 changes: 6 additions & 19 deletions lib/delayed/backend/mongoid.rb
@@ -1,6 +1,5 @@
require 'delayed_job'
require 'mongoid'
require 'mongoid/compatibility'

module Delayed
module Backend
Expand Down Expand Up @@ -33,20 +32,11 @@ def self.db_time_now
# Atomically picks and locks one job from the collection.
def self.reserve(worker, max_run_time = Worker.max_run_time)
right_now = db_time_now

criteria = reservation_criteria worker, right_now, max_run_time

if ::Mongoid::Compatibility::Version.mongoid2? || ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4?
criteria.find_and_modify(
{ '$set' => { locked_at: right_now, locked_by: worker.name } },
new: true
)
else
criteria.find_one_and_update(
{ '$set' => { locked_at: right_now, locked_by: worker.name } },
return_document: :after
)
end
criteria = reservation_criteria(worker, right_now, max_run_time)
criteria.find_one_and_update(
{ '$set' => { locked_at: right_now, locked_by: worker.name } },
return_document: :after
)
end

# Mongo criteria matching all the jobs the worker can reserver
Expand Down Expand Up @@ -84,10 +74,7 @@ def reload(*args)

# Hook method that is called after a new worker is forked
def self.after_fork
if ::Mongoid::Compatibility::Version.mongoid4?
# to avoid `failed with error "unauthorized"` errors in Mongoid 4.0.alpha2
::Mongoid.default_session.disconnect
end
::Mongoid.disconnect_clients
end
end
end
Expand Down
19 changes: 0 additions & 19 deletions lib/delayed/plugins.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/delayed_job_mongoid.rb
@@ -1,7 +1,6 @@
require 'delayed/backend/mongoid'
require 'delayed/serialization/mongoid'
require 'delayed_job'
require 'delayed/plugins'
require 'delayed/yaml/yaml_ext'

Delayed::Worker.backend = :mongoid
4 changes: 2 additions & 2 deletions spec/helper.rb
Expand Up @@ -11,15 +11,15 @@
require 'rspec'
require 'delayed_job_mongoid'
require 'delayed/backend/shared_spec'
require 'mongoid/compatibility'

RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end

config.before :all do
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6?
Mongo::Logger.logger.level = Logger::INFO
end
end

Expand Down
23 changes: 0 additions & 23 deletions spec/plugins_spec.rb

This file was deleted.

0 comments on commit dfada8d

Please sign in to comment.