kestrel-client 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/kestrel-client.gemspec +2 -2
- data/lib/kestrel/client.rb +17 -1
- data/lib/kestrel/client/retry_helper.rb +1 -17
- data/lib/kestrel/client/stats_helper.rb +2 -2
- data/lib/kestrel/client/unmarshal.rb +15 -5
- data/spec/kestrel/client_spec.rb +10 -0
- data/spec/kestrel_benchmark.rb +1 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
data/kestrel-client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kestrel-client}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Freels", "Rael Dornfest"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-19}
|
13
13
|
s.description = %q{Ruby client for the Kestrel queue server}
|
14
14
|
s.email = %q{rael@twitter.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/kestrel/client.rb
CHANGED
@@ -22,6 +22,22 @@ module Kestrel
|
|
22
22
|
:get_timeout_ms => 10
|
23
23
|
}.freeze
|
24
24
|
|
25
|
+
# Exceptions which are connection failures we retry after
|
26
|
+
RECOVERABLE_ERRORS = [
|
27
|
+
Memcached::ServerIsMarkedDead,
|
28
|
+
Memcached::ATimeoutOccurred,
|
29
|
+
Memcached::ConnectionBindFailure,
|
30
|
+
Memcached::ConnectionFailure,
|
31
|
+
Memcached::ConnectionSocketCreateFailure,
|
32
|
+
Memcached::Failure,
|
33
|
+
Memcached::MemoryAllocationFailure,
|
34
|
+
Memcached::ReadFailure,
|
35
|
+
Memcached::ServerError,
|
36
|
+
Memcached::SystemError,
|
37
|
+
Memcached::UnknownReadFailure,
|
38
|
+
Memcached::WriteFailure
|
39
|
+
]
|
40
|
+
|
25
41
|
include StatsHelper
|
26
42
|
include RetryHelper
|
27
43
|
|
@@ -115,7 +131,7 @@ module Kestrel
|
|
115
131
|
val =
|
116
132
|
begin
|
117
133
|
send(select_get_method(key), key + commands, raw)
|
118
|
-
rescue
|
134
|
+
rescue *RECOVERABLE_ERRORS
|
119
135
|
# we can't tell the difference between a server being down
|
120
136
|
# and an empty queue, so just return nil. our sticky server
|
121
137
|
# logic should eliminate piling on down servers
|
@@ -1,26 +1,10 @@
|
|
1
1
|
module Kestrel::Client::RetryHelper
|
2
2
|
|
3
|
-
# Exceptions which are connection failures we retry after
|
4
|
-
RECOVERABLE_ERRORS = [
|
5
|
-
Memcached::ServerIsMarkedDead,
|
6
|
-
Memcached::ATimeoutOccurred,
|
7
|
-
Memcached::ConnectionBindFailure,
|
8
|
-
Memcached::ConnectionFailure,
|
9
|
-
Memcached::ConnectionSocketCreateFailure,
|
10
|
-
Memcached::Failure,
|
11
|
-
Memcached::MemoryAllocationFailure,
|
12
|
-
Memcached::ReadFailure,
|
13
|
-
Memcached::ServerError,
|
14
|
-
Memcached::SystemError,
|
15
|
-
Memcached::UnknownReadFailure,
|
16
|
-
Memcached::WriteFailure
|
17
|
-
]
|
18
|
-
|
19
3
|
private
|
20
4
|
|
21
5
|
def with_retries #:nodoc:
|
22
6
|
yield
|
23
|
-
rescue *RECOVERABLE_ERRORS
|
7
|
+
rescue *Kestrel::Client::RECOVERABLE_ERRORS
|
24
8
|
tries ||= @exception_retry_limit + 1
|
25
9
|
tries -= 1
|
26
10
|
tries > 0 ? retry : raise
|
@@ -11,11 +11,21 @@ module Kestrel
|
|
11
11
|
response
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
|
15
|
+
if RUBY_VERSION.respond_to?(:getbyte)
|
16
|
+
def is_marshaled?(object)
|
17
|
+
o = object.to_s
|
18
|
+
o.getbyte(0) == Marshal::MAJOR_VERSION && o.getbyte(1) == Marshal::MINOR_VERSION
|
19
|
+
rescue Exception
|
20
|
+
false
|
21
|
+
end
|
22
|
+
else
|
23
|
+
def is_marshaled?(object)
|
24
|
+
o = object.to_s
|
25
|
+
o[0] == Marshal::MAJOR_VERSION && o[1] == Marshal::MINOR_VERSION
|
26
|
+
rescue Exception
|
27
|
+
false
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
data/spec/kestrel/client_spec.rb
CHANGED
@@ -30,6 +30,16 @@ describe Kestrel::Client do
|
|
30
30
|
|
31
31
|
3.times { @kestrel.get("a_queue") }
|
32
32
|
end
|
33
|
+
|
34
|
+
it "returns nil if there is a recoverable exception" do
|
35
|
+
mock(@kestrel).select_get_method(@queue) { raise Memcached::SystemError }
|
36
|
+
@kestrel.get(@queue).should == nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises the exception if the exception is not recoverable" do
|
40
|
+
mock(@kestrel).select_get_method(@queue) { raise ArgumentError }
|
41
|
+
lambda { @kestrel.get(@queue) }.should raise_error(ArgumentError)
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
describe "retry behavior" do
|
data/spec/kestrel_benchmark.rb
CHANGED
@@ -20,7 +20,7 @@ describe Kestrel::Client do
|
|
20
20
|
x.report("set:") { for i in 1..times; @kestrel.set(@queue, @value); end }
|
21
21
|
x.report("get:") { for i in 1..times; @kestrel.get(@queue); end }
|
22
22
|
x.report("set (raw):") { for i in 1..times; @kestrel.set(@queue, @raw_value, 0, true); end }
|
23
|
-
x.report("get (raw):") { for i in 1..times; @kestrel.get(@queue, true); end }
|
23
|
+
x.report("get (raw):") { for i in 1..times; @kestrel.get(@queue, :raw => true); end }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kestrel-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Freels
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-01-19 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|