Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Sidekiq patch #9

Merged
merged 4 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Metrics/MethodLength:
Exclude:
- spec/**/*

Style/AsciiComments:
Enabled: false

Style/ClassAndModuleChildren:
Exclude:
- spec/**/*
Expand Down
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ gemfile:
- gemfiles/activejob_4.2.x.gemfile
- gemfiles/activejob_5.2.x.gemfile
- gemfiles/activejob_6.0.x.gemfile
- gemfiles/sidekiq.gemfile
- gemfiles/sidekiq_4.2.x.gemfile
- gemfiles/sidekiq_5.2.x.gemfile
- gemfiles/sidekiq_6.1.x.gemfile
matrix:
exclude:
- rvm: 2.7.1
gemfile: gemfiles/activejob_4.2.x.gemfile
- rvm: 2.7.1
gemfile: gemfiles/sidekiq_4.2.x.gemfile

before_install: gem install bundler -v '~> 2.1.4'
bundler_args: --jobs 3 --retry 3
17 changes: 13 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ appraise 'activejob-6.0.x' do
gem 'activejob', '~> 6.0.3'
end

# FIXME: test more sidekiq versions
appraise 'sidekiq' do
gem 'sidekiq', '~> 6.0.0'
gem 'railties', '~> 6.0.3'
appraise 'sidekiq-4.2.x' do
gem 'sidekiq', '~> 4.2.10'
gem 'activejob', '~> 4.2.11'
end

appraise 'sidekiq-5.2.x' do
gem 'sidekiq', '~> 5.2.9'
gem 'activejob', '~> 5.2.4'
end

appraise 'sidekiq-6.1.x' do
gem 'sidekiq', '~> 6.1.1'
gem 'activejob', '~> 6.0.3'
end
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Fix deprecation warnings for ruby 2.7
Use appraisal gem to control gem versions of tests matrix
[PR](https://github.com/veeqo/activejob-uniqueness/pull/8) by @sharshenov

Refactor jobs unlock by Sidekiq API (fixes NoMethodError on rails/rake commands in 0.1.2)
[PR](https://github.com/veeqo/activejob-uniqueness/pull/9) by @sharshenov

## Changes Between 0.1.1 and 0.1.2

Release lock for Sidekiq adapter when all Sidekiq attempts were unsuccessful or job is deleted manually from Sidekiq::Web
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ gem install wwtd
wwtd
```

## Sidekiq adapter support

ActiveJob::Uniqueness patches Sidekiq API to unset locks on jobs cleanup. Starting Sidekiq 5.1 job death also triggers locks cleanup.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/veeqo/activejob-uniqueness.
Expand Down
8 changes: 8 additions & 0 deletions gemfiles/sidekiq_4.2.x.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "sidekiq", "~> 4.2.10"
gem "activejob", "~> 4.2.11"

gemspec path: "../"
83 changes: 83 additions & 0 deletions gemfiles/sidekiq_4.2.x.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
PATH
remote: ..
specs:
activejob-uniqueness (0.1.3.unreleased)
activejob (>= 4.2, < 7)
redlock (>= 1.2, < 2)

GEM
remote: https://rubygems.org/
specs:
activejob (4.2.11.3)
activesupport (= 4.2.11.3)
globalid (>= 0.3.0)
activesupport (4.2.11.3)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
appraisal (2.3.0)
bundler
rake
thor (>= 0.14.0)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.7)
connection_pool (2.2.3)
diff-lcs (1.4.4)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
method_source (1.0.0)
minitest (5.14.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
rack (2.2.3)
rack-protection (2.0.8.1)
rack
rake (13.0.1)
redis (3.3.5)
redlock (1.2.0)
redis (>= 3.0.0, < 5.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
sidekiq (4.2.10)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
redis (~> 3.2, >= 3.2.1)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
activejob (~> 4.2.11)
activejob-uniqueness!
appraisal (~> 2.3.0)
bundler (>= 2.0)
pry-byebug
rspec (~> 3.0)
sidekiq (~> 4.2.10)

BUNDLED WITH
2.1.4
4 changes: 2 additions & 2 deletions gemfiles/sidekiq.gemfile → gemfiles/sidekiq_5.2.x.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "sidekiq", "~> 6.0.0"
gem "railties", "~> 6.0.3"
gem "sidekiq", "~> 5.2.9"
gem "activejob", "~> 5.2.4"

gemspec path: "../"
83 changes: 83 additions & 0 deletions gemfiles/sidekiq_5.2.x.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
PATH
remote: ..
specs:
activejob-uniqueness (0.1.3.unreleased)
activejob (>= 4.2, < 7)
redlock (>= 1.2, < 2)

GEM
remote: https://rubygems.org/
specs:
activejob (5.2.4.3)
activesupport (= 5.2.4.3)
globalid (>= 0.3.6)
activesupport (5.2.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
appraisal (2.3.0)
bundler
rake
thor (>= 0.14.0)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.7)
connection_pool (2.2.3)
diff-lcs (1.4.4)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
method_source (1.0.0)
minitest (5.14.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
rack (2.2.3)
rack-protection (2.0.8.1)
rack
rake (13.0.1)
redis (4.1.4)
redlock (1.2.0)
redis (>= 3.0.0, < 5.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
sidekiq (5.2.9)
connection_pool (~> 2.2, >= 2.2.2)
rack (~> 2.0)
rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 4.2)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
activejob (~> 5.2.4)
activejob-uniqueness!
appraisal (~> 2.3.0)
bundler (>= 2.0)
pry-byebug
rspec (~> 3.0)
sidekiq (~> 5.2.9)

BUNDLED WITH
2.1.4
8 changes: 8 additions & 0 deletions gemfiles/sidekiq_6.1.x.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "sidekiq", "~> 6.1.1"
gem "activejob", "~> 6.0.3"

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
globalid (>= 0.3.6)
Expand All @@ -34,48 +21,24 @@ GEM
bundler
rake
thor (>= 0.14.0)
builder (3.2.4)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.7)
connection_pool (2.2.3)
crass (1.0.6)
diff-lcs (1.4.4)
erubi (1.9.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
mini_portile2 (2.4.0)
minitest (5.14.1)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
rack (2.2.3)
rack-protection (2.0.8.1)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
redis (4.2.1)
redlock (1.2.0)
Expand All @@ -93,11 +56,10 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
sidekiq (6.0.7)
sidekiq (6.1.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
rack-protection (>= 2.0.0)
redis (>= 4.1.0)
redis (>= 4.2.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
Expand All @@ -108,13 +70,13 @@ PLATFORMS
ruby

DEPENDENCIES
activejob (~> 6.0.3)
activejob-uniqueness!
appraisal (~> 2.3.0)
bundler (>= 2.0)
pry-byebug
railties (~> 6.0.3)
rspec (~> 3.0)
sidekiq (~> 6.0.0)
sidekiq (~> 6.1.1)

BUNDLED WITH
2.1.4
10 changes: 9 additions & 1 deletion lib/active_job/uniqueness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
require 'active_job/uniqueness/version'
require 'active_job/uniqueness/errors'
require 'active_job/uniqueness/log_subscriber'
require 'active_job/uniqueness/patch'
require 'active_job/uniqueness/active_job_patch'

begin
require 'sidekiq/api'
rescue LoadError
# ¯\_(ツ)_/¯
else
require 'active_job/uniqueness/sidekiq_patch'
end

module ActiveJob
module Uniqueness
Expand Down
Loading