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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 576bc9d8d17789876b305414b48cdf74705ef4070e2c0a71fde10f4971bf8668
4
- data.tar.gz: 3f07190b636fbb018476218cbdbb9d4de0867a7df25795dfee8d81af1f1cb190
3
+ metadata.gz: ff1cfb19bc51b7eb8f4040f700650c51a47376e1ec96c84ae72b764227911f0c
4
+ data.tar.gz: 3813cf68d80e7d56d828e15f179c677e49fe2f171780e25c0a6990b7b93eed76
5
5
  SHA512:
6
- metadata.gz: 812b2dd96129d4ee015e1e2e456573e1c27c3a561df9229be27b652ccae70e94215b962b242790c4ea6f046ca99585853e38aee047f14fa23d96e76128b48add
7
- data.tar.gz: 16cc9bc7a899ea72723854904027de0e49c12a2f62c72109bf182cf862735137dd6b2d41131c8b5a13a88f53d77d68137bb645e20fea1a8247dc5fae7e4f3b50
6
+ metadata.gz: b616c4460d8bffe1be31226c3d18d9d3a7197fd714d680ddd636b154934ff648fb5dface28b0099b59ac865a91a5a0cec85a8230ba8d442bda6f831535405b94
7
+ data.tar.gz: 938eb49268486827b8b946934838af755f7f449fc75e84f2cde8538e49af7e786edc13583a715ad86b2203a58867e324e8e580cc611d522e512ae7ed235ddae1
@@ -12,6 +12,7 @@ env:
12
12
  - ACTIVEJOB_VERSION="~> 4.2.11"
13
13
  - ACTIVEJOB_VERSION="~> 5.2.4"
14
14
  - ACTIVEJOB_VERSION="~> 6.0.3"
15
+ - ACTIVEJOB_VERSION="~> 6.0.3" SIDEKIQ_VERSION="~> 6.0.0"
15
16
  jobs:
16
17
  exclude:
17
18
  - rvm: 2.7.1
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveJob
4
4
  module Uniqueness
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  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.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-23 00:00:00.000000000 Z
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