resque_stuck_queue 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +7 -1
- data/THOUGHTS +3 -0
- data/lib/resque_stuck_queue.rb +8 -4
- data/lib/resque_stuck_queue/version.rb +1 -1
- data/test/test_helper.rb +2 -0
- data/test/test_named_queue.rb +35 -0
- data/test/test_resque_stuck_queue.rb +2 -1
- data/test/test_set_custom_refresh_job.rb +0 -1
- metadata +4 -3
- data/Gemfile.lock +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
data.tar.gz:
|
4
|
-
metadata.gz:
|
3
|
+
data.tar.gz: cd305cd673750663559d00b2b6412f19becc6a50
|
4
|
+
metadata.gz: 27e1e7879f29cb47777bfaf71dc85dac57458812
|
5
5
|
SHA512:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
6
|
+
data.tar.gz: 2a99f6cb2b8efa736a22b02ef89245b09f58b86e0ed9189623979e8561d59101b5e88c74c6354a8ee4f26b8a66d5c9e5473a1c471ee4daa893f57136c2f3d8b6
|
7
|
+
metadata.gz: 08d93e4f41bfb98204c7c3cb2c3df9291d65876f11cc339559753be824dfb42f4a79f442eab1e7af0f25daf3647e058cd924172efe0eabc04bd69fb8e8756b80
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -41,6 +41,9 @@ Resque::StuckQueue.config[:handler] = proc { send_email }
|
|
41
41
|
# optional, in case you want to set your own name for the key that will be used as the last good hearbeat time
|
42
42
|
Resque::StuckQueue.config[:global_key] = "name-the-refresh-key-as-you-please"
|
43
43
|
|
44
|
+
# optional, monitor a specific redis queue
|
45
|
+
Resque::StuckQueue.config[:queue_name] = :app
|
46
|
+
|
44
47
|
# optional, if you want the resque-stuck-queue threads to explicitly raise, default is false
|
45
48
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
46
49
|
|
@@ -49,6 +52,9 @@ Resque::StuckQueue.config[:logger] = Logger.new($stdout)
|
|
49
52
|
|
50
53
|
# optional, pass a redis.
|
51
54
|
Resque::StuckQueue.config[:redis] = Redis.new
|
55
|
+
|
56
|
+
# optional, your own custom refresh job. below has an example.
|
57
|
+
Resque::StuckQueue.config[:refresh_job] = proc { your_own_enqueue_refreshing_global_key }
|
52
58
|
</pre>
|
53
59
|
|
54
60
|
Then start it:
|
@@ -103,7 +109,7 @@ $ bundle exec rake --trace resque:stuck_queue
|
|
103
109
|
|
104
110
|
## Sidekiq/Other redis-based job queues
|
105
111
|
|
106
|
-
If you have trouble with other queues you can use this lib by setting your own custom refresh job (aka, the job that refreshes the global_key). The one thing you need to take care of is ensure whatever and however you enque your own custom job, it sets the global_key to Time.now
|
112
|
+
If you have trouble with other queues you can use this lib by setting your own custom refresh job (aka, the job that refreshes the global_key). The one thing you need to take care of is ensure whatever and however you enque your own custom job, it sets the global_key to Time.now:
|
107
113
|
|
108
114
|
<pre>
|
109
115
|
|
data/THOUGHTS
CHANGED
@@ -11,3 +11,6 @@ add a 'resque_stuck_queue/tasks' bit? See tres eg
|
|
11
11
|
require 'resque/stuck_queue' instead?
|
12
12
|
ensure the logging gets flushed into log file correctly? (integration with god?)
|
13
13
|
add a trap{} to force_stop. ok for overwriting process's trap handlers? use config for that?
|
14
|
+
|
15
|
+
fix skeleton recipe https://github.com/shaiguitar/resque_stuck_queue/blame/master/README.md#L103
|
16
|
+
raise appname, => :environment, log path
|
data/lib/resque_stuck_queue.rb
CHANGED
@@ -104,7 +104,11 @@ module Resque
|
|
104
104
|
|
105
105
|
def global_key
|
106
106
|
# public, for use in custom heartbeat job
|
107
|
-
config[:global_key] || GLOBAL_KEY
|
107
|
+
"#{named_queue}:#{config[:global_key] || GLOBAL_KEY}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def named_queue
|
111
|
+
config[:named_queue] || :app
|
108
112
|
end
|
109
113
|
|
110
114
|
private
|
@@ -191,11 +195,11 @@ module Resque
|
|
191
195
|
end
|
192
196
|
|
193
197
|
class RefreshLatestTimestamp
|
194
|
-
@queue =
|
198
|
+
@queue = Resque::StuckQueue.named_queue
|
195
199
|
def self.perform(args)
|
196
200
|
timestamp_key = args[0]
|
197
|
-
host = args[1]
|
198
|
-
port = args[2]
|
201
|
+
host = args[1]
|
202
|
+
port = args[2]
|
199
203
|
r = Redis.new(:host => host, :port => port)
|
200
204
|
r.set(timestamp_key, Time.now.to_i)
|
201
205
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,8 @@ require 'minitest'
|
|
2
2
|
require "minitest/autorun"
|
3
3
|
require 'pry'
|
4
4
|
require 'mocha'
|
5
|
+
require "minitest/unit"
|
6
|
+
require "mocha/mini_test"
|
5
7
|
$:.unshift(".")
|
6
8
|
require 'resque_stuck_queue'
|
7
9
|
require File.join(File.expand_path(File.dirname(__FILE__)), "resque", "set_redis_key")
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
|
2
|
+
|
3
|
+
class TestNamedQueue < Minitest::Test
|
4
|
+
|
5
|
+
include TestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
Resque::StuckQueue.config[:trigger_timeout] = 1
|
9
|
+
Resque::StuckQueue.config[:heartbeat] = 1
|
10
|
+
Resque::StuckQueue.config[:abort_on_exception] = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
Resque::StuckQueue.reset!
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_no_custom_named_queue
|
18
|
+
puts "#{__method__}"
|
19
|
+
Resque::StuckQueue.config[:named_queue] = nil
|
20
|
+
start_and_stop_loops_after(2)
|
21
|
+
assert_equal Resque::StuckQueue.global_key, "app:resque-stuck-queue"
|
22
|
+
assert_equal Resque::StuckQueue.named_queue, :app
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_has_custom_named_queue
|
26
|
+
puts "#{__method__}"
|
27
|
+
Resque::StuckQueue.config[:named_queue] = :foo
|
28
|
+
start_and_stop_loops_after(2)
|
29
|
+
assert_equal Resque::StuckQueue.global_key, "foo:resque-stuck-queue"
|
30
|
+
assert_equal Resque::StuckQueue.named_queue, :foo
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
@@ -7,6 +7,7 @@ class TestResqueStuckQueue < Minitest::Test
|
|
7
7
|
def teardown
|
8
8
|
puts "#{__method__}"
|
9
9
|
Resque::StuckQueue.unstub(:read_from_redis)
|
10
|
+
Resque::StuckQueue.config.clear
|
10
11
|
end
|
11
12
|
|
12
13
|
def setup
|
@@ -22,7 +23,7 @@ class TestResqueStuckQueue < Minitest::Test
|
|
22
23
|
assert_nil Resque.redis.get("it-is-configurable"), "global key should not be set"
|
23
24
|
Resque::StuckQueue.config[:global_key] = "it-is-configurable"
|
24
25
|
start_and_stop_loops_after(2)
|
25
|
-
refute_nil Resque.redis.get("it-is-configurable"), "global key should be set"
|
26
|
+
refute_nil Resque.redis.get("app:it-is-configurable"), "global key should be set"
|
26
27
|
end
|
27
28
|
|
28
29
|
def test_it_does_not_trigger_handler_if_under_max_time
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_stuck_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shai Rosenfeld
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-23 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis-mutex
|
@@ -52,7 +52,6 @@ extra_rdoc_files: []
|
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
54
|
- Gemfile
|
55
|
-
- Gemfile.lock
|
56
55
|
- LICENSE.txt
|
57
56
|
- README.md
|
58
57
|
- Rakefile
|
@@ -67,6 +66,7 @@ files:
|
|
67
66
|
- test/test_helper.rb
|
68
67
|
- test/test_integration.rb
|
69
68
|
- test/test_logger.rb
|
69
|
+
- test/test_named_queue.rb
|
70
70
|
- test/test_resque_2.rb
|
71
71
|
- test/test_resque_stuck_queue.rb
|
72
72
|
- test/test_set_custom_refresh_job.rb
|
@@ -100,6 +100,7 @@ test_files:
|
|
100
100
|
- test/test_helper.rb
|
101
101
|
- test/test_integration.rb
|
102
102
|
- test/test_logger.rb
|
103
|
+
- test/test_named_queue.rb
|
103
104
|
- test/test_resque_2.rb
|
104
105
|
- test/test_resque_stuck_queue.rb
|
105
106
|
- test/test_set_custom_refresh_job.rb
|
data/Gemfile.lock
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/engineyard/resque.git
|
3
|
-
revision: 2949f9f5b035c59a7c03999c00558544837324b5
|
4
|
-
specs:
|
5
|
-
resque (2.0.0.pre.1)
|
6
|
-
json
|
7
|
-
mono_logger (~> 1.0)
|
8
|
-
redis-namespace (>= 1.3.0)
|
9
|
-
thor (~> 0.17)
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: https://rubygems.org/
|
13
|
-
specs:
|
14
|
-
coderay (1.1.0)
|
15
|
-
json (1.8.1)
|
16
|
-
m (1.3.2)
|
17
|
-
method_source (>= 0.6.7)
|
18
|
-
rake (>= 0.9.2.2)
|
19
|
-
metaclass (0.0.1)
|
20
|
-
method_source (0.8.2)
|
21
|
-
minitest (5.2.0)
|
22
|
-
mocha (0.14.0)
|
23
|
-
metaclass (~> 0.0.1)
|
24
|
-
mono_logger (1.1.0)
|
25
|
-
pry (0.9.12.4)
|
26
|
-
coderay (~> 1.0)
|
27
|
-
method_source (~> 0.8)
|
28
|
-
slop (~> 3.4)
|
29
|
-
rake (10.1.0)
|
30
|
-
redis (3.0.6)
|
31
|
-
redis-classy (1.2.0)
|
32
|
-
redis-namespace (~> 1.0)
|
33
|
-
redis-mutex (2.1.1)
|
34
|
-
redis-classy (~> 1.2)
|
35
|
-
redis-namespace (1.4.1)
|
36
|
-
redis (~> 3.0.4)
|
37
|
-
resque-scheduler (2.0.1)
|
38
|
-
redis (>= 2.0.1)
|
39
|
-
resque (>= 1.20.0)
|
40
|
-
rufus-scheduler
|
41
|
-
rufus-scheduler (2.0.19)
|
42
|
-
tzinfo (>= 0.3.23)
|
43
|
-
slop (3.4.7)
|
44
|
-
thor (0.18.1)
|
45
|
-
tzinfo (0.3.38)
|
46
|
-
|
47
|
-
PLATFORMS
|
48
|
-
ruby
|
49
|
-
|
50
|
-
DEPENDENCIES
|
51
|
-
m
|
52
|
-
minitest
|
53
|
-
mocha
|
54
|
-
pry
|
55
|
-
rake
|
56
|
-
redis-mutex
|
57
|
-
resque!
|
58
|
-
resque-scheduler
|