sidekiq-limit_fetch 2.3.0 → 2.4.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: f61efe790fd1a000679bad6e455f85276bd348f1
4
- data.tar.gz: 03db81df3adfa998e350dd2e80a12c09b9a90091
3
+ metadata.gz: af4e92376eea915d5ecb40d3d7183859062bf21c
4
+ data.tar.gz: d596ab1071c952a68eb029a42c3cc4040be33f23
5
5
  SHA512:
6
- metadata.gz: dd35d8ec8c170ba465e1037374daf169828aca0a611c3e0ad4be5385aa0feead331173a383104f879b838406925c54d5b399c3bb20a79def97e05dd011be59cc
7
- data.tar.gz: cf389b01004b864384ab9f4b1b15bcf951e050ec4f83b1fc3e098251f8b640be5018c4f797690fcc14363d9448f152d2f69c7c58d978da2d44f2a36b4c336146
6
+ metadata.gz: 4994be60172a5e21930553db313433ef721c2082fcde29dab9a3b38f9241a0c3da94f216b1e36ebac34c880988100c37394d4b420dac651824d63dbde5ec42a3
7
+ data.tar.gz: a46416a2481d50e3aa67ec45000ad66c4777f35a36e9d9d6ee1b57228eda0bc4599ec7da73594eda64095431c37da402b4384193b90577ef1ccd27bd3aa02231
data/README.md CHANGED
@@ -79,6 +79,7 @@ will be preserved.
79
79
  Sidekiq::Queue['name'].pause # prevents workers from running tasks from this queue
80
80
  Sidekiq::Queue['name'].paused? # => true
81
81
  Sidekiq::Queue['name'].unpause # allows workers to use the queue
82
+ Sidekiq::Queue['name'].pause_for_ms(1000) # will pause for a second
82
83
  ```
83
84
 
84
85
  ### Blocking queue mode
@@ -148,5 +149,6 @@ Dynamic queues will be ran at the lowest priority.
148
149
 
149
150
  ### Thanks
150
151
 
151
- Sponsored by [Evil Martians].
152
- [Evil Martians]: http://evilmartians.com/
152
+ <a href="https://evilmartians.com/?utm_source=sidekiq-limit_fetch">
153
+ <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
154
+
@@ -7,7 +7,7 @@ module Sidekiq
7
7
  :limit, :limit=,
8
8
  :process_limit, :process_limit=,
9
9
  :acquire, :release,
10
- :pause, :unpause,
10
+ :pause, :pause_for_ms, :unpause,
11
11
  :block, :unblock,
12
12
  :paused?, :blocking?,
13
13
  :unblocked, :block_except,
@@ -76,6 +76,10 @@ module Sidekiq::LimitFetch::Global
76
76
  redis {|it| it.set "#{PREFIX}:pause:#@name", true }
77
77
  end
78
78
 
79
+ def pause_for_ms ms
80
+ redis {|it| it.psetex "#{PREFIX}:pause:#@name", ms, true }
81
+ end
82
+
79
83
  def unpause
80
84
  redis {|it| it.del "#{PREFIX}:pause:#@name" }
81
85
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '2.3.0'
3
+ gem.version = '2.4.0'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = 'brainopia'
6
6
  gem.email = 'brainopia@evilmartians.com'
@@ -3,7 +3,8 @@ require 'spec_helper'
3
3
  Thread.abort_on_exception = true
4
4
 
5
5
  describe Sidekiq::LimitFetch::Global::Monitor do
6
- let(:monitor) { described_class.start! ttl, timeout }
6
+ let(:queues) { double dynamic?: false }
7
+ let(:monitor) { described_class.start! queues, ttl, timeout }
7
8
  let(:ttl) { 1 }
8
9
  let(:queue) { Sidekiq::Queue[name] }
9
10
  let(:name) { 'default' }
@@ -52,4 +52,14 @@ describe 'semaphore' do
52
52
  2.times { subject.acquire }
53
53
  subject.probed.should == 2
54
54
  end
55
+
56
+ it 'should pause tasks for a limited time' do
57
+ 3.times { subject.acquire }
58
+ subject.pause_for_ms 50
59
+ 2.times { subject.acquire }
60
+ subject.probed.should == 3
61
+ sleep(100.0 / 1000)
62
+ 2.times { subject.acquire }
63
+ subject.probed.should == 5
64
+ end
55
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-limit_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-21 00:00:00.000000000 Z
11
+ date: 2015-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.4.1
125
+ rubygems_version: 2.4.5
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Sidekiq strategy to support queue limits