ReplSet

Constructor

ReplSet constructor provides replicaset functionality

class ReplSet()
Arguments:
  • list (array) – of server objects participating in the replicaset.
  • [options] (object) – additional options for the replicaset connection.
Options
  • ha {Boolean, default:true}, turn on high availability.
  • haInterval {Number, default:2000}, time between each replicaset status check.
  • reconnectWait {Number, default:1000}, time to wait in miliseconds before attempting reconnect.
  • retries {Number, default:30}, number of times to attempt a replicaset reconnect.
  • rs_name {String}, the name of the replicaset to connect to.
  • socketOptions {Object, default:null}, an object containing socket options to use (noDelay:(boolean), keepAlive:(number), connectTimeoutMS:(number), socketTimeoutMS:(number))
  • strategy {String, default:’ping’}, selection strategy for reads choose between (ping, statistical and none, default is ping)
  • secondaryAcceptableLatencyMS {Number, default:15}, sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms)
  • connectWithNoPrimary {Boolean, default:false}, sets if the driver should connect even if no primary is available
  • connectArbiter {Boolean, default:false}, sets if the driver should connect to arbiters or not.
  • logger {Object, default:null}, an object representing a logger that you want to use, needs to support functions debug, log, error ({error:function(message, object) {}, log:function(message, object) {}, debug:function(message, object) {}}).
  • poolSize {Number, default:5}, number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons.
  • ssl {Boolean, default:false}, use ssl connection (needs to have a mongod server with ssl support)
  • sslValidate {Boolean, default:false}, validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
  • sslCA {Array, default:null}, Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
  • sslCert {Buffer/String, default:null}, String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher)
  • sslKey {Buffer/String, default:null}, String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher)
  • sslPass {Buffer/String, default:null}, String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher)

createServer

Creates a new server for the <code>replset</code> based on <code>host</code>.

createServer(host, replset)
Arguments:
  • host (string) –
    • host:port pair (localhost:27017)
  • replset (replset) –
    • the ReplSet instance
Returns:

server

Contents

Manual

MongoDB Wiki