Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #35 from mediapiston/fix_client_to_work_with_resque

Provide a Client#client stub for Resque interop.
  • Loading branch information...
commit e751b087286560ed80797d32a2431aaf9844e7ac 2 parents 4f349d9 + 844853d
Ryan LeCompte authored
Showing with 22 additions and 0 deletions.
  1. +1 −0  Changes.md
  2. +15 −0 lib/redis_failover/client.rb
  3. +6 −0 spec/client_spec.rb
1  Changes.md
View
@@ -19,6 +19,7 @@
0.9.2
-----------
- Improved exception handling in NodeWatcher.
+- Stubbed Client#client to return itself, fixes a fork reconnect bug with Resque (dbalatero)
0.9.1
-----------
15 lib/redis_failover/client.rb
View
@@ -64,6 +64,21 @@ def initialize(options = {})
build_clients
end
+ # Stubs this method to return this RedisFailover::Client object.
+ #
+ # Some libraries (Resque) assume they can access the `client` via this method,
+ # but we don't want to actually ever expose the internal Redis connections.
+ #
+ # By returning `self` here, we can add stubs for functionality like #reconnect,
+ # and everything will Just Work.
+ #
+ # Takes an *args array for safety only.
+ #
+ # @return [RedisFailover::Client]
+ def client(*args)
+ self
+ end
+
# Specifies a callback to invoke when the current redis node list changes.
#
# @param [Proc] a callback with current master and slaves as arguments
6 spec/client_spec.rb
View
@@ -38,6 +38,12 @@ def setup_zk
end
end
+ describe '#client' do
+ it 'should return itself as a delegate' do
+ client.client.should == client
+ end
+ end
+
describe '#dispatch' do
it 'routes write operations to master' do
called = false
Please sign in to comment.
Something went wrong with that request. Please try again.