resque-waiting-room 0.2.2 → 0.2.3
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/README.markdown +6 -1
- data/lib/resque/plugins/version.rb +1 -1
- data/lib/resque/plugins/waiting_room.rb +10 -3
- data/spec/resque/plugins/waiting_room_spec.rb +4 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc9d18de0b400796244ec7bbcd217f6863e0d7f0
|
4
|
+
data.tar.gz: 6a0aea7bfb129b4727b9f7fd6a2b3117d77418c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c8d82aba863078f20afdd7360bd43d47487975cd40d4a638db36defca78f710690331c0a5947d6365adcf1a56beaa90868aacead0c870aafcfc63eea8523cf
|
7
|
+
data.tar.gz: 69c19f6be8c9f303e5e6243721691b55d0fb347b3785c18a58bc6ae6d6130b4a7ad741de861e838b98282c9625118b3c17ff6076ce7491d7e53933517f7bd3be
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.4
|
data/README.markdown
CHANGED
@@ -56,6 +56,10 @@ We include a matcher
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
Run tests with the following command
|
60
|
+
|
61
|
+
bundle exec rake
|
62
|
+
|
59
63
|
## Contributing
|
60
64
|
|
61
65
|
1. Fork it
|
@@ -68,7 +72,8 @@ We include a matcher
|
|
68
72
|
|
69
73
|
- Thomas Devol [@socialchorus](https://github.com/socialchorus) for adding the RSpec matcher
|
70
74
|
- Max Dunn [@maxdunn210](https://github.com/maxdunn210) for making me switch Resque 2 specific code in it's own branch
|
71
|
-
- Jeff Durand [@johnnyiller](https://github.com/johnnyiller) for the update of has_remaining_performs_key using the latest form set
|
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
|
+
- Tatsuya Takamura [@ttakamura](https://github.com/ttakamura) for raising the issue on the rare ttl bug
|
72
77
|
|
73
78
|
[rq]: http://github.com/resque/resque
|
74
79
|
|
@@ -26,16 +26,23 @@ module Resque
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def remaining_performs_key?(key)
|
29
|
+
# if true then we will only set a key if it doesn't exist
|
30
|
+
# if false then we will set the key regardless. If we have
|
31
|
+
# a negative number then redis either doesn't know about the key
|
32
|
+
# or it doesn't have a ttl, either way we want to create a new key
|
33
|
+
# with a new ttl.
|
34
|
+
nx = Resque.redis.ttl(key).to_i > 0
|
35
|
+
|
29
36
|
# Redis SET: with the ex and nx option sets the keys if it doesn't exist,
|
30
37
|
# returns true if key was created redis => 2.6 required
|
31
|
-
|
32
|
-
|
38
|
+
# http://redis.io/commands/SET
|
39
|
+
!Resque.redis.set(key, @max_performs - 1, ex: @period, nx: nx)
|
33
40
|
end
|
34
41
|
|
35
42
|
def repush(*args)
|
36
43
|
key = waiting_room_redis_key
|
37
44
|
value = Resque.redis.get(key)
|
38
|
-
no_performs_left = value && value !=
|
45
|
+
no_performs_left = value && value != '' && value.to_i <= 0
|
39
46
|
Resque.push 'waiting_room', class: self.to_s, args: args if no_performs_left
|
40
47
|
|
41
48
|
return no_performs_left
|
@@ -72,21 +72,18 @@ describe Resque::Plugins::WaitingRoom do
|
|
72
72
|
|
73
73
|
it 'should set a redis key' do
|
74
74
|
expect(Resque.redis).to receive(:set)
|
75
|
-
.with(@key, @max, ex: @period, nx:
|
75
|
+
.with(@key, @max, ex: @period, nx: false)
|
76
76
|
DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key)
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should expire the redis key' do
|
80
80
|
expect(Resque.redis).to receive(:set)
|
81
|
-
.with(@key, @max, ex: @period, nx:
|
81
|
+
.with(@key, @max, ex: @period, nx: false)
|
82
82
|
.and_return(true)
|
83
83
|
DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key)
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'should not re-expire the redis key if it is already created' do
|
87
|
-
expect(Resque.redis).to receive(:set)
|
88
|
-
.with(@key, @max, ex: @period, nx: true)
|
89
|
-
.and_return(true)
|
90
87
|
DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key)
|
91
88
|
expect(Resque.redis).to receive(:set)
|
92
89
|
.with(@key, @max, ex: @period, nx: true)
|
@@ -96,7 +93,7 @@ describe Resque::Plugins::WaitingRoom do
|
|
96
93
|
|
97
94
|
it 'should return false if the key is new' do
|
98
95
|
expect(Resque.redis).to receive(:set)
|
99
|
-
.with(@key, @max, ex: @period, nx:
|
96
|
+
.with(@key, @max, ex: @period, nx: false)
|
100
97
|
.and_return(true)
|
101
98
|
expect(DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key))
|
102
99
|
.to eq(false)
|
@@ -104,7 +101,7 @@ describe Resque::Plugins::WaitingRoom do
|
|
104
101
|
|
105
102
|
it 'should return true if the key was already created' do
|
106
103
|
expect(Resque.redis).to receive(:set)
|
107
|
-
.with(@key, @max, ex: @period, nx:
|
104
|
+
.with(@key, @max, ex: @period, nx: false)
|
108
105
|
.and_return(false)
|
109
106
|
expect(DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key))
|
110
107
|
.to eq(true)
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Blanchard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|