MongoDB Driver API for Node.js (original) (raw)
Class: Mongos
Mongos
Creates a new Mongos instance
new Mongos(servers, options){Mongos}
Name | Type | Description |
---|---|---|
servers | Array.<Server> | A seedlist of servers participating in the replicaset. |
options | object | optional Optional settings. Name Type Default Description ha booelan true optional Turn on high availability monitoring. haInterval number 5000 optional Time between each replicaset status check. poolSize number 5 optional Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. acceptableLatencyMS number 15 optional Cutoff latency point in MS for MongoS proxy selection ssl boolean false optional Use ssl connection (needs to have a mongod server with ssl support) checkServerIdentity boolean|function true optional Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. sslValidate boolean false optional Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) sslCA array optional Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) sslCRL array optional Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) ciphers string optional Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls\_tls\_createsecurecontext\_options for more info. ecdhCurve string optional Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls\_tls\_createsecurecontext\_options for more info. sslCert Buffer |
Properties:
Name | Type | Description |
---|---|---|
parserType | string | the parser type used (c++ or js). |
Deprecated
- Yes
Fires:
- Mongos#event:connect
- Mongos#event:ha
- Mongos#event:joined
- Mongos#event:left
- Mongos#event:fullsetup
- Mongos#event:open
- Mongos#event:close
- Mongos#event:error
- Mongos#event:timeout
- Mongos#event:parseError
- Mongos#event:commandStarted
- Mongos#event:commandSucceeded
- Mongos#event:commandFailed
Returns:
Mongos instance.
Events
close
Mongos close event
Type:
- object
commandFailed
An event emitted indicating a command failed, if command monitoring is enabled
Type:
- object
commandStarted
An event emitted indicating a command was started, if command monitoring is enabled
Type:
- object
commandSucceeded
An event emitted indicating a command succeeded, if command monitoring is enabled
Type:
- object
connect
A mongos connect event, used to verify that the connection is up and running
Type:
error
Mongos error event, emitted if there is an error listener.
Type:
fullsetup
Mongos fullsetup event, emitted when all proxies in the topology have been connected to.
Type:
ha
The mongos high availability event
Type:
- function
Name | Type | Description |
---|---|---|
type | string | The stage in the high availability event (start|end) |
data.norepeat | boolean | This is a repeating high availability process or a single execution only |
data.id | number | The id for this high availability request |
data.state | object | An object containing the information about the current replicaset |
joined
A server member joined the mongos set
Type:
- function
Name | Type | Description |
---|---|---|
type | string | The type of member that joined (primary|secondary |
server | Server | The server object that joined |
left
A server member left the mongos set
Type:
- function
Name | Type | Description |
---|---|---|
type | string | The type of member that left (primary|secondary |
server | Server | The server object that left |
open
Mongos open event, emitted when mongos can start processing commands.
Type:
parseError
Mongos parseError event
Type:
- object
timeout
Mongos timeout event
Type:
- object