RUBY-252 RUBY-237 re-add Connection#host and Connection#port
This commit is contained in:
parent
2bfe205c51
commit
272d4835a7
|
@ -157,6 +157,20 @@ module Mongo
|
|||
end
|
||||
end
|
||||
|
||||
# The host name used for this connection.
|
||||
#
|
||||
# @return [String]
|
||||
def host
|
||||
@primary_pool.host
|
||||
end
|
||||
|
||||
# The port used for this connection.
|
||||
#
|
||||
# @return [Integer]
|
||||
def port
|
||||
@primary_pool.port
|
||||
end
|
||||
|
||||
# Fsync, then lock the mongod process against writes. Use this to get
|
||||
# the datafiles in a state safe for snapshotting, backing up, etc.
|
||||
#
|
||||
|
|
|
@ -135,6 +135,20 @@ module Mongo
|
|||
@nodes_to_try.length > 0
|
||||
end
|
||||
|
||||
# The replica set primary's host name.
|
||||
#
|
||||
# @return [String]
|
||||
def host
|
||||
super
|
||||
end
|
||||
|
||||
# The replica set primary's port.
|
||||
#
|
||||
# @return [Integer]
|
||||
def port
|
||||
super
|
||||
end
|
||||
|
||||
# Determine whether we're reading from a primary node. If false,
|
||||
# this connection connects to a secondary node and @read_secondaries is true.
|
||||
#
|
||||
|
|
|
@ -22,6 +22,11 @@ class TestConnection < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_host_port_accessors
|
||||
assert_equal @conn.host, TEST_HOST
|
||||
assert_equal @conn.port, TEST_PORT
|
||||
end
|
||||
|
||||
def test_server_info
|
||||
server_info = @conn.server_info
|
||||
assert server_info.keys.include?("version")
|
||||
|
|
|
@ -39,6 +39,14 @@ class ConnectTest < Test::Unit::TestCase
|
|||
assert_equal RS.arbiters.sort, @conn.arbiters.sort
|
||||
end
|
||||
|
||||
def test_host_port_accessors
|
||||
@conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
|
||||
[RS.host, RS.ports[2]], :name => RS.name)
|
||||
|
||||
assert_equal @conn.host, RS.primary[0]
|
||||
assert_equal @conn.port, RS.primary[1]
|
||||
end
|
||||
|
||||
def test_connect_with_primary_node_killed
|
||||
node = RS.kill_primary
|
||||
|
||||
|
|
Loading…
Reference in New Issue