RUBY-247 Improved replica set docs.
This commit is contained in:
parent
2b7739a257
commit
6a46bf7aef
@ -6,12 +6,13 @@ Here follow a few considerations for those using the MongoDB Ruby driver with [r
|
||||
|
||||
First, make sure that you've configured and initialized a replica set.
|
||||
|
||||
Use `ReplSetConnection.new` to connect to a replica set:
|
||||
Use `ReplSetConnection.new` to connect to a replica set. This method, which accepts a variable number of arugments,
|
||||
takes a list of seed nodes followed by any connection options. You'll want to specify at least two seed nodes. This gives
|
||||
the driver more chances to connect in the event that any one seed node is offline. Once the driver connects, it will
|
||||
cache the replica set topology as reported by the given seed node and use that information if a failover is later required.
|
||||
|
||||
@connection = ReplSetConnection.new(['n1.mydb.net', 27017], ['n2.mydb.net', 27017], ['n3.mydb.net', 27017])
|
||||
|
||||
The driver will attempt to connect to a master node and, when found, will replace all seed nodes with known members of the replica set.
|
||||
|
||||
### Read slaves
|
||||
|
||||
If you want to read from a seconday node, you can pass :read_secondary => true to ReplSetConnection#new.
|
||||
|
@ -29,8 +29,8 @@ module Mongo
|
||||
# Connection#arbiters. This is useful if your application needs to connect manually to nodes other
|
||||
# than the primary.
|
||||
#
|
||||
# @param [Array] args A list of host-port pairs ending with a hash containing any options. See
|
||||
# the examples below for exactly how to use the constructor.
|
||||
# @param [Array] args A list of host-port pairs to be used as seed nodes followed by a
|
||||
# hash containing any options. See the examples below for exactly how to use the constructor.
|
||||
#
|
||||
# @option options [String] :rs_name (nil) The name of the replica set to connect to. You
|
||||
# can use this option to verify that you're connecting to the right replica set.
|
||||
@ -47,7 +47,9 @@ module Mongo
|
||||
# this is the number of seconds to wait for a new connection to be released before throwing an exception.
|
||||
# Note: this setting is relevant only for multi-threaded applications.
|
||||
#
|
||||
# @example Connect to a replica set and provide two seed nodes:
|
||||
# @example Connect to a replica set and provide two seed nodes. Note that the number of seed nodes does
|
||||
# not have to be equal to the number of replica set members. The purpose of seed nodes is to permit
|
||||
# the driver to find at least one replica set member even if a member is down.
|
||||
# ReplSetConnection.new(['localhost', 30000], ['localhost', 30001])
|
||||
#
|
||||
# @example Connect to a replica set providing two seed nodes and ensuring a connection to the replica set named 'prod':
|
||||
|
Loading…
Reference in New Issue
Block a user