stalking 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stalking/consumer.rb +3 -7
- data/lib/stalking/producer.rb +8 -8
- data/lib/stalking/version.rb +1 -1
- data/lib/stalking.rb +1 -0
- data/stalking.gemspec +1 -0
- data/test/stalking/consumer_test.rb +1 -1
- data/test/stalking/producer_test.rb +1 -1
- data/test/stalking/test_logger.rb +4 -0
- metadata +18 -2
data/lib/stalking/consumer.rb
CHANGED
@@ -56,7 +56,7 @@ module Stalking
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
rescue EOFError, Beanstalk::NotConnected => e
|
59
|
-
|
59
|
+
@logger.andand.error e.message
|
60
60
|
|
61
61
|
sleep 1
|
62
62
|
|
@@ -64,7 +64,7 @@ module Stalking
|
|
64
64
|
|
65
65
|
retry
|
66
66
|
rescue => e
|
67
|
-
|
67
|
+
@logger.andand.error e.message
|
68
68
|
|
69
69
|
raise e
|
70
70
|
end
|
@@ -98,7 +98,7 @@ module Stalking
|
|
98
98
|
|
99
99
|
@connection
|
100
100
|
rescue Beanstalk::NotConnected => e
|
101
|
-
|
101
|
+
@logger.andand.error e.message
|
102
102
|
|
103
103
|
sleep 1
|
104
104
|
|
@@ -112,10 +112,6 @@ module Stalking
|
|
112
112
|
|
113
113
|
connect
|
114
114
|
end
|
115
|
-
|
116
|
-
def log_error(e)
|
117
|
-
@logger.error("Stalking error: #{e.message}") if @logger
|
118
|
-
end
|
119
115
|
end
|
120
116
|
end
|
121
117
|
|
data/lib/stalking/producer.rb
CHANGED
@@ -18,11 +18,13 @@ module Stalking
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def enqueue(name, args = {}, options = {})
|
21
|
+
@logger.andand.info "Enqueue #{name.inspect} with #{args.inspect} and #{options.inspect}"
|
22
|
+
|
21
23
|
# Send the job to a random server.
|
22
24
|
|
23
25
|
@servers.shuffle.first(@tries).each do |server|
|
24
26
|
begin
|
25
|
-
Timeout::timeout
|
27
|
+
Timeout::timeout @timeout do
|
26
28
|
@connections[server] ||= Beanstalk::Pool.new([server])
|
27
29
|
|
28
30
|
enq @connections[server], name, args, options
|
@@ -34,7 +36,7 @@ module Stalking
|
|
34
36
|
# Let's try to reconnect and enqueue afterwards.
|
35
37
|
|
36
38
|
begin
|
37
|
-
Timeout::timeout
|
39
|
+
Timeout::timeout @timeout do
|
38
40
|
@connections[server] = Beanstalk::Pool.new([server])
|
39
41
|
|
40
42
|
enq @connections[server], name, args, options
|
@@ -42,13 +44,15 @@ module Stalking
|
|
42
44
|
|
43
45
|
return true
|
44
46
|
rescue Beanstalk::NotConnected, Timeout::Error, StandardError => e
|
45
|
-
|
47
|
+
@logger.andand.error e.message
|
46
48
|
end
|
47
49
|
rescue Timeout::Error, StandardError => e
|
48
|
-
|
50
|
+
@logger.andand.error e.message
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
54
|
+
@logger.andand.error "Enqueue #{name.inspect} with #{args.inspect} and #{options.inspect} failed"
|
55
|
+
|
52
56
|
# All servers are currently unavailable.
|
53
57
|
# Enqueuing the job has failed.
|
54
58
|
|
@@ -65,10 +69,6 @@ module Stalking
|
|
65
69
|
connection.use name
|
66
70
|
connection.put [name, args].to_json, pri, delay, ttr
|
67
71
|
end
|
68
|
-
|
69
|
-
def log_error(e)
|
70
|
-
@logger.error("Stalking error: #{e.message}") if @logger
|
71
|
-
end
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
data/lib/stalking/version.rb
CHANGED
data/lib/stalking.rb
CHANGED
data/stalking.gemspec
CHANGED
@@ -199,7 +199,7 @@ class Stalking::ConsumerTest < Test::Unit::TestCase
|
|
199
199
|
|
200
200
|
assert_equal [["down"], ["test", { "a" => "b" }]], res
|
201
201
|
|
202
|
-
assert_equal ["
|
202
|
+
assert_equal ["Beanstalk::NotConnected"], logger.messages
|
203
203
|
end
|
204
204
|
|
205
205
|
def test_logger
|
@@ -80,7 +80,7 @@ class Stalking::ProducerTest < Test::Unit::TestCase
|
|
80
80
|
|
81
81
|
producer.enqueue "test", "up" => "true"
|
82
82
|
|
83
|
-
assert_equal ["
|
83
|
+
assert_equal ['Enqueue "test" with {"up"=>"true"} and {}', "Beanstalk::NotConnected", 'Enqueue "test" with {"up"=>"true"} and {} failed'], logger.messages
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stalking
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: andand
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
description: Asynchronous job processing using the beanstalkd queue server with automatic
|
63
79
|
reconnects and failover
|
64
80
|
email:
|