activejob-uniqueness 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +5 -0
- data/lib/active_job/uniqueness/patch.rb +5 -0
- data/lib/active_job/uniqueness/patch/sidekiq.rb +93 -0
- data/lib/active_job/uniqueness/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff1cfb19bc51b7eb8f4040f700650c51a47376e1ec96c84ae72b764227911f0c
|
4
|
+
data.tar.gz: 3813cf68d80e7d56d828e15f179c677e49fe2f171780e25c0a6990b7b93eed76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b616c4460d8bffe1be31226c3d18d9d3a7197fd714d680ddd636b154934ff648fb5dface28b0099b59ac865a91a5a0cec85a8230ba8d442bda6f831535405b94
|
7
|
+
data.tar.gz: 938eb49268486827b8b946934838af755f7f449fc75e84f2cde8538e49af7e786edc13583a715ad86b2203a58867e324e8e580cc611d522e512ae7ed235ddae1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## Changes Between 0.1.1 and 0.1.2
|
2
|
+
|
3
|
+
Release lock for Sidekiq adapter when all Sidekiq attempts were unsuccessful or job is deleted manually from Sidekiq::Web
|
4
|
+
[PR](https://github.com/veeqo/activejob-uniqueness/pull/5) by @vbyno
|
5
|
+
|
1
6
|
## Changes Between 0.1.0 and 0.1.1
|
2
7
|
|
3
8
|
Fixed NoMethodError on `Rails.application.eager_load!` in Rails initializer
|
data/Gemfile
CHANGED
@@ -8,3 +8,8 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
8
8
|
gemspec
|
9
9
|
|
10
10
|
gem 'activejob', ENV.fetch('ACTIVEJOB_VERSION', '~> 4.2.11')
|
11
|
+
|
12
|
+
if ENV['SIDEKIQ_VERSION']
|
13
|
+
gem 'sidekiq', ENV.fetch('SIDEKIQ_VERSION')
|
14
|
+
gem 'railties', ENV.fetch('ACTIVEJOB_VERSION')
|
15
|
+
end
|
@@ -74,6 +74,11 @@ module ActiveJob
|
|
74
74
|
|
75
75
|
ActiveSupport.on_load(:active_job) do
|
76
76
|
ActiveJob::Base.include ActiveJob::Uniqueness::Patch
|
77
|
+
|
78
|
+
if ::ActiveJob.const_defined?(:Railtie) &&
|
79
|
+
ActiveJob::Railtie.config.active_job.queue_adapter.to_sym == :sidekiq
|
80
|
+
require_relative 'patch/sidekiq'
|
81
|
+
end
|
77
82
|
end
|
78
83
|
end
|
79
84
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveJob
|
4
|
+
module Uniqueness
|
5
|
+
module Patch
|
6
|
+
def self.delete_sidekiq_job!(job)
|
7
|
+
ActiveJob::Uniqueness.unlock!(
|
8
|
+
job_class_name: job.fetch('wrapped'),
|
9
|
+
arguments: job.fetch('args').first.fetch('arguments')
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'sidekiq/api'
|
17
|
+
|
18
|
+
Sidekiq.configure_server do |config|
|
19
|
+
config.death_handlers << ->(job, _ex) do
|
20
|
+
ActiveJob::Uniqueness::Patch.delete_sidekiq_job!(job)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Sidekiq
|
25
|
+
class SortedEntry
|
26
|
+
module UniqueExtension
|
27
|
+
def delete
|
28
|
+
ActiveJob::Uniqueness::Patch.delete_sidekiq_job!(item) if super
|
29
|
+
item
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def remove_job
|
35
|
+
super do |message|
|
36
|
+
ActiveJob::Uniqueness::Patch.delete_sidekiq_job!(Sidekiq.load_json(message))
|
37
|
+
yield message
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
prepend UniqueExtension
|
43
|
+
end
|
44
|
+
|
45
|
+
class ScheduledSet
|
46
|
+
module UniqueExtension
|
47
|
+
def delete(score, job_id)
|
48
|
+
entry = find_job(job_id)
|
49
|
+
ActiveJob::Uniqueness::Patch.delete_sidekiq_job!(entry.item) if super(score, job_id)
|
50
|
+
entry
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
prepend UniqueExtension
|
55
|
+
end
|
56
|
+
|
57
|
+
class Job
|
58
|
+
module UniqueExtension
|
59
|
+
def delete
|
60
|
+
ActiveJob::Uniqueness::Patch.delete_sidekiq_job!(item)
|
61
|
+
super
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
prepend UniqueExtension
|
66
|
+
end
|
67
|
+
|
68
|
+
class Queue
|
69
|
+
module UniqueExtension
|
70
|
+
def clear
|
71
|
+
each(&:delete)
|
72
|
+
super
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
prepend UniqueExtension
|
77
|
+
end
|
78
|
+
|
79
|
+
class JobSet
|
80
|
+
module UniqueExtension
|
81
|
+
def clear
|
82
|
+
each(&:delete)
|
83
|
+
super
|
84
|
+
end
|
85
|
+
|
86
|
+
def delete_by_value(name, value)
|
87
|
+
ActiveJob::Uniqueness::Patch.delete_sidekiq_job!(Sidekiq.load_json(value)) if super(name, value)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
prepend UniqueExtension
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-uniqueness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Sharshenov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/active_job/uniqueness/lock_manager.rb
|
125
125
|
- lib/active_job/uniqueness/log_subscriber.rb
|
126
126
|
- lib/active_job/uniqueness/patch.rb
|
127
|
+
- lib/active_job/uniqueness/patch/sidekiq.rb
|
127
128
|
- lib/active_job/uniqueness/strategies.rb
|
128
129
|
- lib/active_job/uniqueness/strategies/base.rb
|
129
130
|
- lib/active_job/uniqueness/strategies/until_and_while_executing.rb
|