resque-waiting-room 0.2.3 → 0.3.0
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/.travis.yml +3 -3
- data/Gemfile +1 -1
- data/README.markdown +1 -0
- data/lib/resque/plugins/version.rb +1 -1
- data/lib/resque/plugins/waiting_room.rb +4 -4
- data/resque-waiting-room.gemspec +13 -12
- data/spec/resque/plugins/waiting_room_spec.rb +5 -0
- metadata +4 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee4bf23cad9fb42befe7e128de9a876a985db041
|
4
|
+
data.tar.gz: 6bce8e148ed490c2fc31a4939eda93d231b3ec6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 050bde21ca53609034825bb2e4198cbf4d4939f0065277dc902a8518ad7780604d59686490944d00c75b588a34133aec84dc762823d48bdc5e18bc0a4a084f62
|
7
|
+
data.tar.gz: 6750e5a4995fe7a37df564525c3d3f4c0831804abb1037a614af8c0581e4496feea2452a9041ef24aceb1f7de9639f68db73f953041a1ecee19494abbda2e699
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.3
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -74,6 +74,7 @@ Run tests with the following command
|
|
74
74
|
- Max Dunn [@maxdunn210](https://github.com/maxdunn210) for making me switch Resque 2 specific code in it's own branch
|
75
75
|
- Jeff Durand [@johnnyiller](https://github.com/johnnyiller) for the update of has_remaining_performs_key using the latest form set and the fix for a rare ttl bug
|
76
76
|
- Tatsuya Takamura [@ttakamura](https://github.com/ttakamura) for raising the issue on the rare ttl bug
|
77
|
+
- Omry Zobel [@omryYotpo](https://github.com/omryYotpo) for allowing some customization of the redis key
|
77
78
|
|
78
79
|
[rq]: http://github.com/resque/resque
|
79
80
|
|
@@ -4,18 +4,18 @@ module Resque
|
|
4
4
|
class MissingParams < RuntimeError; end
|
5
5
|
|
6
6
|
def can_be_performed(params)
|
7
|
-
raise MissingParams unless params.is_a?(Hash) && params.keys.sort == [
|
7
|
+
raise MissingParams unless params.is_a?(Hash) && params.keys.sort == %i[period times]
|
8
8
|
|
9
9
|
@period ||= params[:period]
|
10
10
|
@max_performs ||= params[:times].to_i
|
11
11
|
end
|
12
12
|
|
13
|
-
def waiting_room_redis_key
|
13
|
+
def waiting_room_redis_key(*_args)
|
14
14
|
[self.to_s, 'remaining_performs'].compact.join(':')
|
15
15
|
end
|
16
16
|
|
17
17
|
def before_perform_waiting_room(*args)
|
18
|
-
key = waiting_room_redis_key
|
18
|
+
key = waiting_room_redis_key(args)
|
19
19
|
return unless remaining_performs_key?(key)
|
20
20
|
|
21
21
|
performs_left = Resque.redis.decrby(key, 1).to_i
|
@@ -40,7 +40,7 @@ module Resque
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def repush(*args)
|
43
|
-
key = waiting_room_redis_key
|
43
|
+
key = waiting_room_redis_key(args)
|
44
44
|
value = Resque.redis.get(key)
|
45
45
|
no_performs_left = value && value != '' && value.to_i <= 0
|
46
46
|
Resque.push 'waiting_room', class: self.to_s, args: args if no_performs_left
|
data/resque-waiting-room.gemspec
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('../lib/resque/plugins', __FILE__)
|
4
|
+
require 'version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
+
s.name = 'resque-waiting-room'
|
7
8
|
s.version = Resque::Plugins::WaitingRoom::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
9
|
+
s.authors = ['Julien Blanchard']
|
10
|
+
s.email = ['julien@sideburns.eu']
|
11
|
+
s.homepage = 'https://www.github.com/julienXX/resque-waiting-room'
|
12
|
+
s.summary = 'Put your Resque jobs in a waiting room'
|
13
|
+
s.description = 'Throttle your Resque jobs'
|
13
14
|
|
14
|
-
s.rubyforge_project =
|
15
|
+
s.rubyforge_project = 'resque-waiting-room'
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.files += Dir.glob(
|
20
|
-
s.files += Dir.glob(
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
|
+
s.files += Dir.glob('lib/**/*')
|
21
|
+
s.files += Dir.glob('spec/**/*')
|
21
22
|
|
22
23
|
s.add_development_dependency 'rake'
|
23
24
|
s.add_development_dependency 'resque'
|
@@ -26,6 +26,11 @@ describe Resque::Plugins::WaitingRoom do
|
|
26
26
|
expect(DummyJob.waiting_room_redis_key)
|
27
27
|
.to eq('DummyJob:remaining_performs')
|
28
28
|
end
|
29
|
+
|
30
|
+
it 'can have args passed to' do
|
31
|
+
expect(DummyJob.waiting_room_redis_key('123', '111', '4444'))
|
32
|
+
.to eq('DummyJob:remaining_performs')
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
context 'custom matcher' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-waiting-room
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Blanchard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -82,13 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project: resque-waiting-room
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.6.14
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Put your Resque jobs in a waiting room
|
89
|
-
test_files:
|
90
|
-
- spec/resque/plugins/job_spec.rb
|
91
|
-
- spec/resque/plugins/waiting_room_spec.rb
|
92
|
-
- spec/spec_helper.rb
|
93
|
-
- spec/support/dummy_job.rb
|
94
|
-
- spec/support/matchers.rb
|
89
|
+
test_files: []
|