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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d4face3e0849052a2927072c56bf46be03935a30396a753cd77b1e7eaf7f712
4
- data.tar.gz: 8ef8a5cfc6300c524ba994c4a3f1376e3b3f3858618a155bf2919131bed3de3c
3
+ metadata.gz: 3a0a010e61296a6a1fdf584470177a01db0325a899ee6a6cae9e683b6a498b5c
4
+ data.tar.gz: 077e870580c431a04c1c73797b8cf4fe8364289f3a11c4d15788045f65f069be
5
5
  SHA512:
6
- metadata.gz: 144457fd0ad603ed99e494070837c8b2cb30505a0bc0048a48ea9087026de410391a78a0c82a5e3c886777d04e8fa632324a4c4c73690310572108f0fbf4761f
7
- data.tar.gz: 9396809dd975fee4a0a7447aa7ba53f1054b07356bda808d6c36344be3e8bf7dc431cb5916d5fdf9df2f7cc668bd464157d583ac2e338df5adcb686254ac3750
6
+ metadata.gz: 9cca947e010dec20bf88146f014caa1021091034ce1709e4e1f60db189da51aefc198a3fb53bde6d1be4206271576fe87ef012f7d6533f9f272ee3755b0585fc
7
+ data.tar.gz: ce2b3b6191f93fee6dcaaf9ddeac62750d4d3cbb1218a6540fd47367ce74dea0370a05793d61840c645f9e4377f978f091f2a558f8f2fb4434985f449ecb3b74
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.4
1
+ 3.0.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unique_job (0.4.3)
4
+ unique_job (0.4.4)
5
5
  redis
6
6
  sidekiq (> 6.0, < 7.0)
7
7
 
@@ -40,4 +40,4 @@ DEPENDENCIES
40
40
  unique_job!
41
41
 
42
42
  BUNDLED WITH
43
- 2.1.4
43
+ 2.2.22
@@ -18,7 +18,7 @@ module UniqueJob
18
18
  else
19
19
  worker = worker_str.new
20
20
  end
21
- perform_if_unique(worker, job['args'], &block)
21
+ perform(worker, job, &block)
22
22
  end
23
23
  end
24
24
  end
@@ -9,7 +9,7 @@ module UniqueJob
9
9
  end
10
10
 
11
11
  def call(worker, msg, queue, &block)
12
- perform_if_unique(worker, msg['args'], &block)
12
+ perform(worker, msg, &block)
13
13
  end
14
14
  end
15
15
  end
@@ -5,16 +5,17 @@ module UniqueJob
5
5
  module Util
6
6
  include Logging
7
7
 
8
- def perform_if_unique(worker, args, &block)
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] Calculate unique key worker=#{worker.class} key=#{unique_key}" }
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 check_uniqueness(worker, unique_key)
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=#{worker.class} key=#{unique_key}" }
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 check_uniqueness(worker, key)
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
@@ -1,3 +1,3 @@
1
1
  module UniqueJob
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
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.3
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: 2021-12-05 00:00:00.000000000 Z
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.1.6
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: []