unique_job 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +2 -2
- data/lib/unique_job/client_middleware.rb +1 -1
- data/lib/unique_job/server_middleware.rb +1 -1
- data/lib/unique_job/util.rb +8 -15
- data/lib/unique_job/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a0a010e61296a6a1fdf584470177a01db0325a899ee6a6cae9e683b6a498b5c
|
4
|
+
data.tar.gz: 077e870580c431a04c1c73797b8cf4fe8364289f3a11c4d15788045f65f069be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cca947e010dec20bf88146f014caa1021091034ce1709e4e1f60db189da51aefc198a3fb53bde6d1be4206271576fe87ef012f7d6533f9f272ee3755b0585fc
|
7
|
+
data.tar.gz: ce2b3b6191f93fee6dcaaf9ddeac62750d4d3cbb1218a6540fd47367ce74dea0370a05793d61840c645f9e4377f978f091f2a558f8f2fb4434985f449ecb3b74
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.2
|
data/Gemfile.lock
CHANGED
data/lib/unique_job/util.rb
CHANGED
@@ -5,16 +5,17 @@ module UniqueJob
|
|
5
5
|
module Util
|
6
6
|
include Logging
|
7
7
|
|
8
|
-
def
|
8
|
+
def perform(worker, job, &block)
|
9
9
|
if worker.respond_to?(:unique_key)
|
10
|
-
unique_key = worker.unique_key(*args)
|
11
|
-
logger.debug { "[UniqueJob]
|
10
|
+
unique_key = worker.unique_key(*job['args'])
|
11
|
+
logger.debug { "[UniqueJob] Unique key calculated worker=#{job['class']} key=#{unique_key}" }
|
12
12
|
|
13
|
-
if
|
13
|
+
if unique?(worker, unique_key)
|
14
|
+
elsif unique?(worker, unique_key)
|
14
15
|
yield
|
15
16
|
else
|
16
|
-
logger.debug { "[UniqueJob] Duplicate job skipped worker=#{
|
17
|
-
perform_callback(worker, :after_skip, args)
|
17
|
+
logger.debug { "[UniqueJob] Duplicate job skipped worker=#{job['class']} key=#{unique_key}" }
|
18
|
+
perform_callback(worker, :after_skip, job['args'])
|
18
19
|
nil
|
19
20
|
end
|
20
21
|
else
|
@@ -22,7 +23,7 @@ module UniqueJob
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
+
def unique?(worker, key)
|
26
27
|
if key.nil? || key.to_s.empty?
|
27
28
|
logger.warn { "[UniqueJob] Don't check a job with a blank key worker=#{worker.class} key=#{key}" }
|
28
29
|
return false
|
@@ -44,14 +45,6 @@ module UniqueJob
|
|
44
45
|
JobHistory.new(worker.class, self.class, ttl)
|
45
46
|
end
|
46
47
|
|
47
|
-
def truncate(text, length: 100)
|
48
|
-
if text.length > length
|
49
|
-
text.slice(0, length)
|
50
|
-
else
|
51
|
-
text
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
48
|
def perform_callback(worker, callback_name, args)
|
56
49
|
if worker.respond_to?(callback_name)
|
57
50
|
parameters = worker.method(callback_name).parameters
|
data/lib/unique_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unique_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ts-3156
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -78,7 +78,7 @@ metadata:
|
|
78
78
|
homepage_uri: https://github.com/egotter/unique_job
|
79
79
|
source_code_uri: https://github.com/egotter/unique_job
|
80
80
|
changelog_uri: https://github.com/egotter/unique_job
|
81
|
-
post_install_message:
|
81
|
+
post_install_message:
|
82
82
|
rdoc_options: []
|
83
83
|
require_paths:
|
84
84
|
- lib
|
@@ -93,8 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
97
|
-
signing_key:
|
96
|
+
rubygems_version: 3.2.22
|
97
|
+
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Set a uniqueness to Sidekiq jobs
|
100
100
|
test_files: []
|