minor: whitespace
This commit is contained in:
parent
29cc4b20e2
commit
6301a41254
|
@ -514,11 +514,11 @@ module Mongo
|
|||
end
|
||||
|
||||
protected
|
||||
|
||||
|
||||
def valid_opts
|
||||
GENERIC_OPTS + CONNECTION_OPTS
|
||||
end
|
||||
|
||||
|
||||
def check_opts(opts)
|
||||
bad_opts = opts.keys.reject { |opt| valid_opts.include?(opt) }
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ module Mongo
|
|||
|
||||
# Instantiates and manages connections to a MongoDB replica set.
|
||||
class ReplSetConnection < Connection
|
||||
|
||||
|
||||
REPL_SET_OPTS = [:read, :refresh_mode, :refresh_interval, :require_primary, :read_secondary, :rs_name]
|
||||
|
||||
attr_reader :replica_set_name, :seeds, :refresh_interval, :refresh_mode,
|
||||
|
@ -85,11 +85,11 @@ module Mongo
|
|||
else
|
||||
opts = {}
|
||||
end
|
||||
|
||||
|
||||
unless args.length > 0
|
||||
raise MongoArgumentError, "A ReplSetConnection requires at least one seed node."
|
||||
end
|
||||
|
||||
|
||||
# This is temporary until support for the old format is dropped
|
||||
@seeds = []
|
||||
if args.first.last.is_a?(Integer)
|
||||
|
@ -103,30 +103,30 @@ module Mongo
|
|||
seeds << seed
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# TODO: add a method for replacing this list of node.
|
||||
@seeds.freeze
|
||||
|
||||
|
||||
# Refresh
|
||||
@last_refresh = Time.now
|
||||
@refresh_version = 0
|
||||
|
||||
# No connection manager by default.
|
||||
@manager = nil
|
||||
|
||||
|
||||
# Lock for request ids.
|
||||
@id_lock = Mutex.new
|
||||
|
||||
|
||||
@pool_mutex = Mutex.new
|
||||
@connected = false
|
||||
|
||||
|
||||
@safe_mutex_lock = Mutex.new
|
||||
@safe_mutexes = Hash.new {|hash, key| hash[key] = Mutex.new}
|
||||
|
||||
|
||||
check_opts(opts)
|
||||
setup(opts)
|
||||
end
|
||||
|
||||
|
||||
def valid_opts
|
||||
GENERIC_OPTS + REPL_SET_OPTS
|
||||
end
|
||||
|
@ -450,11 +450,11 @@ module Mongo
|
|||
def setup(opts)
|
||||
# Require a primary node to connect?
|
||||
@require_primary = opts.fetch(:require_primary, true)
|
||||
|
||||
|
||||
# Refresh
|
||||
@refresh_mode = opts.fetch(:refresh_mode, false)
|
||||
@refresh_interval = opts[:refresh_interval] || 90
|
||||
|
||||
|
||||
if @refresh_mode == :async
|
||||
warn ":async refresh mode has been deprecated. Refresh
|
||||
mode will be disabled."
|
||||
|
|
|
@ -26,30 +26,30 @@ class ConnectionTest < Test::Unit::TestCase
|
|||
should "default slave_ok to false" do
|
||||
assert !@conn.slave_ok?
|
||||
end
|
||||
|
||||
|
||||
should "warn if invalid options are specified" do
|
||||
conn = Connection.allocate
|
||||
opts = {:connect => false}
|
||||
|
||||
|
||||
ReplSetConnection::REPL_SET_OPTS.each do |opt|
|
||||
conn.expects(:warn).with("#{opt} is not a valid option for #{conn.class}")
|
||||
opts[opt] = true
|
||||
end
|
||||
|
||||
|
||||
args = ['localhost', 27017, opts]
|
||||
conn.send(:initialize, *args)
|
||||
end
|
||||
|
||||
|
||||
context "given a replica set" do
|
||||
should "warn if invalid options are specified" do
|
||||
conn = ReplSetConnection.allocate
|
||||
opts = {:connect => false}
|
||||
|
||||
|
||||
Connection::CONNECTION_OPTS.each do |opt|
|
||||
conn.expects(:warn).with("#{opt} is not a valid option for #{conn.class}")
|
||||
opts[opt] = true
|
||||
end
|
||||
|
||||
|
||||
args = [['localhost:27017'], opts]
|
||||
conn.send(:initialize, *args)
|
||||
end
|
||||
|
@ -73,21 +73,21 @@ class ConnectionTest < Test::Unit::TestCase
|
|||
@conn = Connection.from_uri("mongodb://#{host_name}/foo", :connect => false)
|
||||
assert_equal [host_name, 27017], @conn.host_to_try
|
||||
end
|
||||
|
||||
|
||||
should "set safe options on connection" do
|
||||
host_name = "localhost"
|
||||
opts = "safe=true&w=2&wtimeoutMS=1000&fsync=true&journal=true"
|
||||
@conn = Connection.from_uri("mongodb://#{host_name}/foo?#{opts}", :connect => false)
|
||||
assert_equal({:w => 2, :wtimeout => 1000, :fsync => true, :j => true}, @conn.safe)
|
||||
end
|
||||
|
||||
|
||||
should "have wtimeoutMS take precidence over the depricated wtimeout" do
|
||||
host_name = "localhost"
|
||||
opts = "safe=true&wtimeout=100&wtimeoutMS=500"
|
||||
@conn = Connection.from_uri("mongodb://#{host_name}/foo?#{opts}", :connect => false)
|
||||
assert_equal({:wtimeout => 500}, @conn.safe)
|
||||
end
|
||||
|
||||
|
||||
should "set timeout options on connection" do
|
||||
host_name = "localhost"
|
||||
opts = "connectTimeoutMS=1000&socketTimeoutMS=5000"
|
||||
|
|
Loading…
Reference in New Issue