From 35099260716a54fdd1b52e5e2cc102004d077e95 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Tue, 29 Mar 2011 12:18:58 -0400 Subject: [PATCH] Remove Connection#reset_connection (private) and deprecate ReplSetConnection#reset_connection (public) --- lib/mongo/connection.rb | 4 ++-- lib/mongo/repl_set_connection.rb | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index 5cbb76b..d7caf0e 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -475,7 +475,7 @@ module Mongo # # @raise [ConnectionFailure] if unable to connect to any host or port. def connect - reset_connection + close config = check_is_master(@host_to_try) if config @@ -536,6 +536,7 @@ module Mongo def close @primary_pool.close if @primary_pool @primary_pool = nil + @primary = nil end # Returns the maximum BSON object size as returned by the core server. @@ -668,7 +669,6 @@ module Mongo # TODO: evaluate whether this method is actually necessary def reset_connection close - @primary = nil end def check_is_master(node) diff --git a/lib/mongo/repl_set_connection.rb b/lib/mongo/repl_set_connection.rb index 3f03fdd..8ce120a 100644 --- a/lib/mongo/repl_set_connection.rb +++ b/lib/mongo/repl_set_connection.rb @@ -101,7 +101,7 @@ module Mongo # # @raise [ConnectionFailure] if unable to connect to any host or port. def connect - reset_connection + close @nodes_to_try = @nodes.clone while connecting? @@ -165,13 +165,6 @@ module Mongo @secondary_pools.each do |pool| pool.close end - end - - # If a ConnectionFailure is raised, this method will be called - # to close the connection and reset connection values. - # TODO: what's the point of this method? - def reset_connection - super @secondaries = [] @secondary_pools = [] @arbiters = [] @@ -179,6 +172,15 @@ module Mongo @nodes_to_try = [] end + # If a ConnectionFailure is raised, this method will be called + # to close the connection and reset connection values. + # @deprecated + def reset_connection + close + warn "ReplSetConnection#reset_connection is now deprecated. " + + "Use ReplSetConnection#close instead." + end + # Is it okay to connect to a slave? # # @return [Boolean]