activejob-uniqueness 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +4 -0
- data/lib/active_job/uniqueness/active_job_patch.rb +4 -4
- data/lib/active_job/uniqueness/lock_key.rb +8 -0
- data/lib/active_job/uniqueness/strategies/base.rb +4 -4
- data/lib/active_job/uniqueness/strategies/until_and_while_executing.rb +9 -9
- data/lib/active_job/uniqueness/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3892ccb031a8fe8b0bc47154ed236dda2a700b404dbcc9063b83479fbe264dc7
|
4
|
+
data.tar.gz: 73a8f4866017e2310bc0c966a49d2f25578921ad64b2e23a2c28931923b34b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a47bdbedbc98c95c24983ae4f46652f6c5f10584cfbe65312b4ee336a2d3fae21d03d6ea4c6b3fd09760cd5e9cfd3dde2fe02a89423e0918a6de0353a6f90c9b
|
7
|
+
data.tar.gz: ebfcf1e76b74662f5fb60008789b1858061c8685783a87317dff5818637064519894780f941c6a543687e02952747db2105e872efb95079e5b321a4f149e38bd
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,12 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
5
5
|
|
6
|
-
## [Unreleased](https://github.com/veeqo/activejob-uniqueness/compare/v0.2.
|
6
|
+
## [Unreleased](https://github.com/veeqo/activejob-uniqueness/compare/v0.2.2...HEAD)
|
7
|
+
|
8
|
+
## [0.2.2](https://github.com/veeqo/activejob-uniqueness/compare/v0.2.1...v0.2.2) - 2021-10-22
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- [#32](https://github.com/veeqo/activejob-uniqueness/pull/32) Add ability to set a custom runtime lock key for `:until_and_while_executing` strategy
|
7
12
|
|
8
13
|
## [0.2.1](https://github.com/veeqo/activejob-uniqueness/compare/v0.2.0...v0.2.1) - 2021-08-24
|
9
14
|
|
data/README.md
CHANGED
@@ -55,7 +55,7 @@ module ActiveJob
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def lock_strategy
|
58
|
-
@lock_strategy ||= lock_strategy_class.new(
|
58
|
+
@lock_strategy ||= lock_strategy_class.new(job: self)
|
59
59
|
end
|
60
60
|
|
61
61
|
# Override in your job class if you want to customize arguments set for a digest.
|
@@ -64,11 +64,11 @@ module ActiveJob
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Override lock_key method in your job class if you want to build completely custom lock key.
|
67
|
-
delegate :lock_key, to: :lock_key_generator
|
67
|
+
delegate :lock_key, :runtime_lock_key, to: :lock_key_generator
|
68
68
|
|
69
69
|
def lock_key_generator
|
70
|
-
ActiveJob::Uniqueness::LockKey.new job_class_name: self.class.name,
|
71
|
-
|
70
|
+
@lock_key_generator ||= ActiveJob::Uniqueness::LockKey.new job_class_name: self.class.name,
|
71
|
+
arguments: lock_key_arguments
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -13,10 +13,10 @@ module ActiveJob
|
|
13
13
|
|
14
14
|
attr_reader :lock_key, :lock_ttl, :on_conflict, :job
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
@lock_key = lock_key
|
18
|
-
@lock_ttl = (lock_ttl || config.lock_ttl).to_i * 1000 # ms
|
19
|
-
@on_conflict = on_conflict || config.on_conflict
|
16
|
+
def initialize(job:)
|
17
|
+
@lock_key = job.lock_key
|
18
|
+
@lock_ttl = (job.lock_options[:lock_ttl] || config.lock_ttl).to_i * 1000 # ms
|
19
|
+
@on_conflict = job.lock_options[:on_conflict] || config.on_conflict
|
20
20
|
@job = job
|
21
21
|
end
|
22
22
|
|
@@ -9,12 +9,16 @@ module ActiveJob
|
|
9
9
|
class UntilAndWhileExecuting < Base
|
10
10
|
include LockingOnEnqueue
|
11
11
|
|
12
|
-
attr_reader :runtime_lock_ttl, :on_runtime_conflict
|
12
|
+
attr_reader :runtime_lock_key, :runtime_lock_ttl, :on_runtime_conflict
|
13
13
|
|
14
|
-
def initialize(
|
15
|
-
super
|
16
|
-
@
|
17
|
-
|
14
|
+
def initialize(job:)
|
15
|
+
super
|
16
|
+
@runtime_lock_key = job.runtime_lock_key
|
17
|
+
|
18
|
+
runtime_lock_ttl_option = job.lock_options[:runtime_lock_ttl]
|
19
|
+
@runtime_lock_ttl = runtime_lock_ttl_option.present? ? runtime_lock_ttl_option.to_i * 1000 : lock_ttl
|
20
|
+
|
21
|
+
@on_runtime_conflict = job.lock_options[:on_runtime_conflict] || on_conflict
|
18
22
|
end
|
19
23
|
|
20
24
|
def before_perform
|
@@ -33,10 +37,6 @@ module ActiveJob
|
|
33
37
|
ensure
|
34
38
|
unlock(resource: runtime_lock_key, event: :runtime_unlock) unless @job_aborted
|
35
39
|
end
|
36
|
-
|
37
|
-
def runtime_lock_key
|
38
|
-
[lock_key, 'runtime'].join(':')
|
39
|
-
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
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.2.
|
4
|
+
version: 0.2.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: 2021-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|