RUBY-378 new ReplSetConnection format
This commit is contained in:
parent
fec284ee99
commit
78fc1debbe
|
@ -90,9 +90,21 @@ module Mongo
|
|||
raise MongoArgumentError, "A ReplSetConnection requires at least one seed node."
|
||||
end
|
||||
|
||||
# The original, immutable list of seed node.
|
||||
# TODO: add a method for replacing this list of node.
|
||||
# This is temporary until support for the old format is dropped
|
||||
@seeds = []
|
||||
if args.first.last.is_a?(Integer)
|
||||
warn "Initiating a ReplSetConnection with seeds passed as individual [host, port] array arguments is deprecated."
|
||||
warn "Please specify hosts as 'host:port' strings; the old format will be removed in v2.0"
|
||||
@seeds = args
|
||||
else
|
||||
args.first.map do |host_port|
|
||||
seed = host_port.split(":")
|
||||
seed[1] = seed[1].to_i
|
||||
seeds << seed
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: add a method for replacing this list of node.
|
||||
@seeds.freeze
|
||||
|
||||
# TODO: get rid of this
|
||||
|
|
|
@ -109,6 +109,11 @@ class ConnectTest < Test::Unit::TestCase
|
|||
assert @conn.connected?
|
||||
end
|
||||
|
||||
def test_connect_with_new_seed_format
|
||||
@conn = ReplSetConnection.new(["#{@rs.host}:#{@rs.ports[0]}','#{@rs.host}:#{@rs.ports[1]}','#{@rs.host}:#{@rs.ports[2]}"])
|
||||
assert @conn.connected?
|
||||
end
|
||||
|
||||
def test_connect_with_full_connection_string
|
||||
@conn = Connection.from_uri("mongodb://#{@rs.host}:#{@rs.ports[0]},#{@rs.host}:#{@rs.ports[1]}?replicaset=#{@rs.name};safe=true;w=2;fsync=true;slaveok=true")
|
||||
assert @conn.is_a?(ReplSetConnection)
|
||||
|
|
Loading…
Reference in New Issue