Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix some bugs in list_keys, add ping to the client.

  • Loading branch information...
commit 5df7ef062c187893f0fbe528c21bf4655e67ae81 1 parent 44a258e
@seancribbs seancribbs authored
View
6 riak-client/lib/riak/client.rb
@@ -222,6 +222,12 @@ def backend
end
end
+ # Pings the Riak server to check for liveness.
+ # @return [true,false] whether the Riak server is alive and reachable
+ def ping
+ backend.ping
+ end
+
# Retrieves a bucket from Riak.
# @param [String] bucket the bucket to retrieve
# @param [Hash] options options for retrieving the bucket
View
13 riak-client/lib/riak/client/beefcake_protobuffs_backend.rb
@@ -97,11 +97,14 @@ def list_keys(bucket, &block)
req = RpbListKeysReq.new(:bucket => bucket)
write_protobuff(:ListKeysReq, req)
keys = []
- block = block_given? ? Pump.new(block).to_proc : lambda {|kl| keys.concat kl }
- res = decode_response
- while res.respond_to?(:done) && !res.done
- block.call res.keys
- res = decode_response
+ pump = Pump.new(block) if block_given?
+ while msg = decode_response
+ break if msg.done
+ if pump
+ pump.pump msg.keys
+ else
+ keys += msg.keys
+ end
end
block_given? || keys
end
View
4 riak-client/spec/support/drb_mock_server.rb
@@ -7,7 +7,7 @@ module DrbMockServer
def start_client
# JRuby doesn't support fork
if defined? JRUBY_VERSION
- @server = MockServer.new
+ @server = MockServer.new(2)
at_exit { @server.stop }
else
child_pid = Process.fork do
@@ -17,6 +17,7 @@ def start_client
at_exit { Process.kill("HUP", child_pid); Process.wait2 }
DRb.start_service
@server = DRbObject.new_with_uri(DRBURI)
+ sleep 1
end
true
end
@@ -29,7 +30,6 @@ def method_missing(meth, *args, &block)
@server.send(meth, *args, &block)
end
- private
def start_server
server = MockServer.new
DRb.start_service(DRBURI, server)
View
11 riak-client/spec/support/mock_server.rb
@@ -18,6 +18,7 @@
require 'rack'
require 'openssl'
require 'webrick/https'
+require 'rack/handler/webrick'
class MockServer
attr_accessor :port
@@ -33,11 +34,11 @@ def initialize(pause = 1)
end
@ssl_thread = Thread.new do
Rack::Handler::WEBrick.run(self, options.merge(:Port => port+1,
- :SSLEnable => true,
- :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
- :SSLCertificate => read_cert,
- :SSLPrivateKey => read_pkey,
- :SSLCertName => [ [ "CN",'127.0.0.1' ] ]))
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => read_cert,
+ :SSLPrivateKey => read_pkey,
+ :SSLCertName => [ [ "CN",'127.0.0.1' ] ]))
end
sleep pause # give the server time to fire up… YUK!
end
Please sign in to comment.
Something went wrong with that request. Please try again.