sidekiq-unique-jobs 4.0.7 → 4.0.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d354eaf8918e64ccbe7873ea1bc4a2f04392d78
4
- data.tar.gz: 048516acc45e64d59f19e2f080b98d975a4b2d65
3
+ metadata.gz: 64a81ae8142ce1f78d40061b8c1fbe11cd9ec79a
4
+ data.tar.gz: 6fe4d1d19eaa60088d3a7a46ee9761b7de1cfecb
5
5
  SHA512:
6
- metadata.gz: 481a2053ca531710e228bf8d2da432f353c5f14af4f3d82f9748271ee190cf10ff9fcd1fb353bf16942fa56277cef5f31a0413d63ebdc657e653f56809533753
7
- data.tar.gz: 104340d1f76fc29dab974c93afe7823ff673fa20a4349a819320fdb1f87916eba3b21f11d8484e8b1abaaca558500eca5a3296bc0fb56eb8b99669162822ed0b
6
+ metadata.gz: 7b0044b2721c29fa5ffbb342c670c2d8f087719c12e7ad59dc9a30e25b9d9a1ba54bd3cdbbe738202bc4f39a1c27835a1e964837ccdec57fc01c43c2ed0efd6e
7
+ data.tar.gz: 2429e2b73e64cbbdb2972278309ca45ecb1dccff56777c65f15dacd05162c59c755d7a55a1c93cbbc71c13bcc4bfdb71a03496dda881842ddc0b5a3205237008
data/LICENSE CHANGED
@@ -1,22 +1,13 @@
1
- Copyright (c) 2012 Mikael Henriksson
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
2
3
 
3
- MIT License
4
+ Copyright (C) 2015 Mikael Henriksson <mikael@zoolutions.se>
4
5
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
12
9
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
15
12
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/README.md CHANGED
@@ -30,7 +30,7 @@ Or install it yourself as:
30
30
 
31
31
  ## A word on locking
32
32
 
33
- Like @mperham mentions on (this wiki page)[https://github.com/mperham/sidekiq/wiki/Related-Projects#unique-jobs] it is hard to enforce uniqueness with redis in a distributed redis setting.
33
+ Like @mperham mentions on [this wiki page](https://github.com/mperham/sidekiq/wiki/Related-Projects#unique-jobs) it is hard to enforce uniqueness with redis in a distributed redis setting.
34
34
 
35
35
  To make things worse there are many ways of wanting to enforce uniqueness.
36
36
 
@@ -2,11 +2,8 @@ module SidekiqUniqueJobs
2
2
  module Lock
3
3
  class UntilTimeout < UntilExecuted
4
4
  def unlock(scope)
5
- if scope.to_sym == :server
6
- return true
7
- else
8
- fail ArgumentError, "#{scope} middleware can't #{__method__} #{unique_key}"
9
- end
5
+ return true if scope.to_sym == :server
6
+ fail ArgumentError, "#{scope} middleware can't #{__method__} #{unique_key}"
10
7
  end
11
8
 
12
9
  def execute(_callback)
@@ -21,7 +21,7 @@ module SidekiqUniqueJobs
21
21
  @item = job
22
22
  @worker_class ||= worker_class_constantize(@item[CLASS_KEY])
23
23
  @item[UNIQUE_PREFIX_KEY] ||= unique_prefix
24
- @item[UNIQUE_ARGS_KEY] ||= unique_args(@item[ARGS_KEY])
24
+ @item[UNIQUE_ARGS_KEY] = unique_args(@item[ARGS_KEY]) # SIC! Calculate unique_args unconditionally
25
25
  @item[UNIQUE_DIGEST_KEY] ||= unique_digest
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module SidekiqUniqueJobs
2
- VERSION = '4.0.7'
2
+ VERSION = '4.0.8'
3
3
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ['mikael@zoolutions.se']
7
7
  gem.description = gem.summary = 'The unique jobs that were removed from sidekiq'
8
8
  gem.homepage = 'https://github.com/mhenrixon/sidekiq-unique-jobs'
9
- gem.license = 'LGPL-3.0'
9
+ gem.license = 'WTFPL-2.0'
10
10
 
11
11
  # gem.executables = ['']
12
12
  gem.files = `git ls-files`.split("\n")
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'celluloid/current'
3
+ rescue LoadError
4
+ warn 'Celluloid is old'
5
+ begin
6
+ require 'celluloid' rescue LoadError
7
+ rescue LoadError
8
+ warn 'Celluloid not found'
9
+ end
10
+ end
11
+ begin
12
+ require 'celluloid' rescue LoadError
13
+ rescue LoadError
14
+ # do nothing we already know
15
+ end
16
+
17
+ Celluloid.boot if defined?(Celluloid)
@@ -1,7 +1,7 @@
1
1
  class CustomQueueJobWithFilterMethod < CustomQueueJob
2
2
  sidekiq_options unique: :until_executed, unique_args: :args_filter
3
3
 
4
- def self.args_filter(*args)
4
+ def self.args_filter(args)
5
5
  args.first
6
6
  end
7
7
  end
@@ -2,9 +2,9 @@ class CustomQueueJobWithFilterProc < CustomQueueJob
2
2
  # slightly contrived example of munging args to the
3
3
  # worker and removing a random bit.
4
4
  sidekiq_options unique: :until_timeout,
5
- unique_args: (lambda do |*args|
5
+ unique_args: (lambda do |args|
6
6
  options = args.extract_options!
7
- options.delete(:random)
8
- [args, options]
7
+ options.delete('random')
8
+ args + [options]
9
9
  end)
10
10
  end
@@ -4,6 +4,49 @@ RSpec.describe SidekiqUniqueJobs::UniqueArgs do
4
4
  let(:item) { { 'class' => 'UntilExecutedJob', 'queue' => 'myqueue', 'args' => [[1, 2]] } }
5
5
  subject { described_class.new(item) }
6
6
 
7
+ describe '#unique_digest' do
8
+ let(:item) { item_options.merge('args' => [1, 2, 'type' => 'it'] ) }
9
+
10
+ shared_examples 'unique digest' do
11
+ context 'given another item' do
12
+ let(:another_subject) { described_class.new(another_item) }
13
+
14
+ context 'with the same unique args' do
15
+ let(:another_item) { item_options.merge('args' => [1, 2, 'type' => 'it']) }
16
+ it 'equals to unique_digest for that item' do
17
+ expect(subject.unique_digest).to eq(another_subject.unique_digest)
18
+ end
19
+ end
20
+
21
+ context 'with different unique args' do
22
+ let(:another_item) { item_options.merge('args' => [1, 3, 'type' => 'that']) }
23
+ it 'differs from unique_digest for that item' do
24
+ expect(subject.unique_digest).to_not eq(another_subject.unique_digest)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ context 'when unique_args is a proc' do
31
+ let(:item_options) do
32
+ { 'class' => 'UntilExecutedJob', 'queue' => 'myqueue',
33
+ 'unique_args' => Proc.new { |args| args[1] } }
34
+ end
35
+
36
+
37
+ it_behaves_like 'unique digest'
38
+ end
39
+
40
+ context 'when unique_args is a symbol' do
41
+ let(:item_options) do
42
+ { 'class' => 'UniqueJobWithFilterMethod', 'queue' => 'myqueue',
43
+ 'unique_args' => :filtered_args }
44
+ end
45
+
46
+ it_behaves_like 'unique digest'
47
+ end
48
+ end
49
+
7
50
  describe '#unique_args_enabled?' do
8
51
  with_default_worker_options(unique: :until_executed, unique_args: ->(args) { args[1]['test'] }) do
9
52
  with_sidekiq_options_for(UntilExecutedJob, unique_args: :unique_args) do
@@ -16,14 +16,7 @@ end
16
16
  require 'rspec'
17
17
  require 'rspec/its'
18
18
 
19
- begin
20
- require 'celluloid/current'
21
- rescue LoadError
22
- warn 'Celluloid is old'
23
- require 'celluloid'
24
- end
25
- require 'celluloid/test'
26
- Celluloid.boot
19
+ require 'celluloid_with_fallback'
27
20
  require 'sidekiq'
28
21
  require 'sidekiq/util'
29
22
  require 'sidekiq-unique-jobs'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2015-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -150,6 +150,7 @@ files:
150
150
  - redis/release_lock.lua
151
151
  - redis/synchronize.lua
152
152
  - sidekiq-unique-jobs.gemspec
153
+ - spec/celluloid_with_fallback.rb
153
154
  - spec/jobs/another_unique_job.rb
154
155
  - spec/jobs/custom_queue_job.rb
155
156
  - spec/jobs/custom_queue_job_with_filter_method.rb
@@ -191,7 +192,7 @@ files:
191
192
  - spec/support/unique_macros.rb
192
193
  homepage: https://github.com/mhenrixon/sidekiq-unique-jobs
193
194
  licenses:
194
- - LGPL-3.0
195
+ - WTFPL-2.0
195
196
  metadata: {}
196
197
  post_install_message: 'WARNING: VERSION 4.0.0 HAS BREAKING CHANGES! Please see Readme
197
198
  for info'
@@ -210,9 +211,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  version: '0'
211
212
  requirements: []
212
213
  rubyforge_project:
213
- rubygems_version: 2.4.8
214
+ rubygems_version: 2.4.5.1
214
215
  signing_key:
215
216
  specification_version: 4
216
217
  summary: The unique jobs that were removed from sidekiq
217
218
  test_files: []
218
- has_rdoc: