sidekiq-middleware 0.2.1 → 0.3.0

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
  SHA1:
3
- metadata.gz: 609eb41397719043e799e6d311934fd35d16e858
4
- data.tar.gz: 9cda80867210d8a012225fb75481354d6f2242b4
3
+ metadata.gz: e8bb4d8b8fa9b2c5fd7d043b86e1c4f10ea235de
4
+ data.tar.gz: f401129a7df9563cdbb542123009715b5c531ef3
5
5
  SHA512:
6
- metadata.gz: 203ae14906166bbf98c759bb9d6b6ae2308c152009ffefd470d81f69dff88809ff97d5666ea29cc1b7e80155d6e7e5acf6bd4316f69d4e9a881bb47ca6b07e59
7
- data.tar.gz: b9c90463c8f03574784263b41daf28b2d18ba8d3aca3b24364fb6a918890327bf98b5f40b130939e4f8a53f51767fb1a9c059dc7c8a6ec1f2f44e893faee1dc4
6
+ metadata.gz: bb6d7bbe8e8f11f962ff5520ddf46bc0c4f9553ad557b8e3116236b82c2c51c065e05c762a025b7e9c1a33e1b7725ac13606130befdd3b6e60e0319322f7099c
7
+ data.tar.gz: 53810297993f7ebbc77dcb661af8a0b4b68a2078a8e321dc8d1bf023edd59f9e4956d4a3950134865a657156604b4380c973a6ca7d018933ec8a3ef3e37e2219
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
4
  - 2.1.0
5
+ - 2.1.1
6
6
  branches:
7
7
  only:
8
8
  - master
@@ -2,14 +2,13 @@ module Sidekiq
2
2
  module Middleware
3
3
  module Client
4
4
  class UniqueJobs
5
- def call(worker_class, item, queue)
5
+ def call(worker_class, item, queue, redis_pool = nil)
6
6
  worker_class = worker_class.constantize if worker_class.is_a?(String)
7
7
  enabled = Sidekiq::Middleware::Helpers.unique_enabled?(worker_class, item)
8
8
 
9
9
  if enabled
10
10
  expiration = Sidekiq::Middleware::Helpers.unique_exiration(worker_class)
11
11
  job_id = item['jid']
12
- unique = false
13
12
 
14
13
  # Scheduled
15
14
  if item.has_key?('at')
@@ -20,17 +19,11 @@ module Sidekiq
20
19
 
21
20
  unique_key = Sidekiq::Middleware::Helpers.unique_digest(worker_class, item)
22
21
 
23
- Sidekiq.redis do |conn|
24
- conn.watch(unique_key)
25
-
26
- locked_job_id = conn.get(unique_key)
27
- if locked_job_id && locked_job_id != job_id
28
- conn.unwatch
29
- else
30
- unique = conn.multi do
31
- conn.setex(unique_key, expiration, job_id)
32
- end
33
- end
22
+ # Sidekiq >= 3.0
23
+ unique = if redis_pool
24
+ redis_pool.with { |conn| status(conn, unique_key, expiration, job_id) }
25
+ else
26
+ Sidekiq.redis { |conn| status(conn, unique_key, expiration, job_id) }
34
27
  end
35
28
 
36
29
  yield if unique
@@ -38,6 +31,22 @@ module Sidekiq
38
31
  yield
39
32
  end
40
33
  end
34
+
35
+ def status(conn, unique_key, expiration, job_id)
36
+ unique = false
37
+ conn.watch(unique_key)
38
+
39
+ locked_job_id = conn.get(unique_key)
40
+ if locked_job_id && locked_job_id != job_id
41
+ conn.unwatch
42
+ else
43
+ unique = conn.multi do
44
+ conn.setex(unique_key, expiration, job_id)
45
+ end
46
+ end
47
+
48
+ unique
49
+ end
41
50
  end
42
51
  end
43
52
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Middleware
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ["lib"]
15
15
  gem.version = Sidekiq::Middleware::VERSION
16
16
 
17
- gem.add_dependency 'sidekiq', '>= 2.12.4', '< 3'
17
+ gem.add_dependency 'sidekiq', '>= 2.12.4'
18
18
  gem.add_development_dependency 'rake'
19
19
  gem.add_development_dependency 'bundler', '~> 1.0'
20
20
  gem.add_development_dependency 'minitest', '~> 3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Krasnoukhov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.12.4
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '3'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.12.4
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '3'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
124
  version: '0'
131
125
  requirements: []
132
126
  rubyforge_project:
133
- rubygems_version: 2.2.0.rc.1
127
+ rubygems_version: 2.2.2
134
128
  signing_key:
135
129
  specification_version: 4
136
130
  summary: Additional sidekiq middleware