Profiles
Overview
Profiles are Javascript files that contain the cluster configuration and settings to connect to the core database of SOAJS.
Every service/daemon need this information so that SOAJS loads the Registry Information and thus be able to deploy it.
A profile is supplied via an environment variable before running the node . command
Sections
- Explain a Profile code sample
- Example Profiles for:
- Client configuration for Single Instance Mongo DB Server
- Client configuration for Replica Set Mongo DB Server
- Full List of Supported Options for Mongo Client v2.2
Code Sample
The profile file contains the registry information that tells SOAJS the location of the core database server to use. This file gives SOAJS the information to load the core configuration and provide it to the service.
module.exports = { "name": "core_provision", "prefix": "", "servers": [ { "host": "127.0.0.1", "port": 27017 } ], "credentials": null, "streaming": { "batchSize" : 10000 }, "URLParam": { "maxPoolSize": 2, "bufferMaxEntries": 0 } };
The above file, tells SOAJS that the location of core_provision where the core information resides is at "127.0.0.1" via port "27017" and that no credentials are needed to connect to it.
The remaining properties and details of URLParam are needed by MongoDB Client Driver to establish a connection to the database. This information is explained and documented on Mongodb Website.
If you are familiar with MongoDB driver configuration, you can update the content of this file to support multiple servers, add credentials and restrict the database connection to specific accounts, provide support for replicaSet...etc
Examples
Single Instance
'use strict'; module.exports = { "name": "core_provision", "prefix": "", "servers": [ { "host": "127.0.0.1", "port": 27017 } ], "credentials": null, "streaming": { "batchSize" : 10000, "colName":{ "batchSize" : 10000 } }, "URLParam": { "maxPoolSize": 2, "bufferMaxEntries": 0 } };
Replica Set
'use strict'; module.exports = { "name": "core_provision", "prefix": "", "servers": [ { "host": "dataProxy-01", "port": 27017 }, { "host": "dataProxy-02", "port": 27017 }, { "host": "dataProxy-03", "port": 27017 } ], "credentials": null, "streaming": { "batchSize" : 10000, "colName":{ "batchSize" : 10000 } }, "URLParam": { "readPreference": "secondaryPreferred", "replicaSet": "rs", "w": "majority", "bufferMaxEntries": 0, "ha": true, "poolSize": 2 } };
Full List of Mongo Client Options
module.exports = { "URLParam": { "poolSize": 5, //Default poolsize value "ssl": false, //Whether or not the connection requires SSL "sslCA": null, //Array of valid certificates either as Buffers or Strings "sslCert": null, //String or buffer containing the certificate we wish to present "sslKey": null, //String or buffer containing the certificate private key we wish to present "sslPass": null, //String or buffer containing the certificate password "checkServerIdentity": true, //Ensure we check server identify during SSL, set to false to disable checking "autoReconnect": true, //Reconnect on error for Single Server instances only "noDelay": true, //TCP Socket NoDelay option "keepAlive": 0, //TCP KeepAlive on the socket with a X ms delay before start "connectTimeoutMS": 30000, //connection timeout value in ms or 0 for never "socketTimeoutMS": 30000, //socket timeout value to attempt connection in ms or 0 for n "reconnectTries": 30, //Server attempt to reconnect #times "reconnectInterval": 1000, //Server will wait # milliseconds between retries "ha": true, //Turn on high availability monitoring. "haInterval": 10000, //Time between each replicaset status check "replicaSet": "rs", "secondaryAcceptableLatencyMS": 15, //Sets the range of servers to pick when using NEAREST "acceptableLatencyMS": 15, //Sets the range of servers to pick when using NEAREST "connectWithNoPrimary": false, //Sets if the driver should connect even if no primary is available "authSource": null, //specify a db to authenticate the user if the one he is connecting to doesn't do that "w": "majority", //values majority|number|<tag set> "wtimeoutMS": 0, //timeout for w, 0 is for never "j": false, //Specify a journal write concern. "forceServerObjectId": false, //Force server to assign _id values instead of driver. default=false "serializeFunctions": false, //Serialize functions on any object. default=false "ignoreUndefined": false, //Specify if the BSON serializer should ignore undefined fields. default=false "raw": false, //Return document results as raw BSON buffers. default=false "promoteLongs": true, //Promotes Long values to number if they fit inside the 53 bits reso "promoteBuffers": false, //Promotes Binary BSON values to native Node Buffers. ( new ) "promoteValues": true, //Promotes BSON values to native types where possible, set to false to only receive wrapper types. ( new ) "bufferMaxEntries": -1, //Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. "readPreference": "secondaryPreferred", "domainsEnabled": false, //Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. "pkFactory": null, //A primary key factory object for generation of custom _id keys. "promiseLibrary": null, //A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible "readConcern": null, "maxStalenessSeconds": 10, //The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); "loggerLevel": "error|warn|info|debug", //The logging level "logger": {} //Custom logger object } };