-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Runtime Configurations
Here are the all runtime configurations of Pomelo.
This config can only be applied to master server.
- Desc: The function to auth user.
- Type: Function.
- Default value: utils.defaultAuthUser from 'pomelo-admin'.
- Desc: The function to auth server.
- Type: Function.
- Default value: utils.defaultAuthServerMaster from 'pomelo-admin'.
app.configure('production|development', 'master', function(){
app.set('masterConfig', {
authUser: function () { ... },
authServer: function () { ... }
});
});
The config affects the client of 'pomelo-rpc'. It can be applied to all servers except master server.
- Desc: This flag determines whether the pomelo-rpc sends the message directly or not. If true, it will send the message every 'interval (see below)' milliseconds. If false, it will send the directly.
- Type: Boolean.
- Default value: Not set, which will be evaluated as false.
- Desc: See above. The unit is millisecond. Used when bufferMsg is true.
- Type: Number.
- Default value: 50.
- Desc: The seconds that failure action will fire after rpc was called. Unit is second.
- Type: Number.
- Default value: 30.
app.configure('production|development', function(){
app.set('proxyConfig', {
bufferMsg: true,
interval: 20
});
});
The config affects the server of 'pomelo-rpc'. It can be applied to all servers except master server..
- Same as proxyConfig.bufferMsg.
- Same as proxyConfig.interval.
- Desc: Function to provide valid IPs.
- Type: Function.
- Default value: Not set.
app.configure('production|development', function(){
app.set('remoteConfig', {
bufferMsg: true,
interval: 20
});
});
Not implemented.
This config is for connector. It can only be applied to frontend servers.
- Desc: Function to encode data which will be sent over network.
- Type: Function.
- Default value: Provided by connector.
- Desc: Function to decode data received from network.
- Type: Function.
- Default value: Provided by connector.
- Desc: If true, pomelo will use RSA to verify the integrity of the message sent by client.
- Type: Boolean.
- Default value: Not set, which will be evaluated as false.
- Desc: Function to filter IPv4 address.
- Type: Function.
- Default value: Not set (Do not use this feature, use 'iptables' to filter IPs).
If you insist to use this feature, Here is one implementation:
function blacklistFun (cb) {
var badIpList = ['192.168.1.1', '192.168.1.2'];
cb(null, badIpList);
}
- Desc: Enable route compression or not. If true, pomelo will try to read dictionary from $APPBASE/config/dictionary.json. You can override this by providing dictionaryConfig. See below.
- Type: Boolean.
- Default value: Not set, which will be evaluated as false.
- Desc: Enable protobuf or not. If true, pomelo will try to read config from $APPBASE/config/clientProtos.json and $APPBASE/config/serverProtos.json. You can override this by providing protobufConfig. See below.
- Type: Boolean.
- Default value: Not set, which will be evaluated as false.
- Desc: The type of connector.
- Type: Object.
- Default value: sioconnector.
- Desc: The interval to send heartbeat packet. Unit is second.
- Type: Number.
- Default value: Not set.
- Desc: Disconnect the socket if not receive the heartbeat in time.
- Type: Boolean.
- Default value: Not set.
- Desc: Seconds to receive heartbeat. Used when disconnectOnTimeout is true. Unit is second.
- Type: Number.
- Default value: Not set.
- Desc: Function will be called at handshake.
- Type: Function.
- Default value: Not set.
- Desc: Handshake function.
- Type: Function.
- Default value: Not set.
- Desc: Disable nagle's algorithm.
- Type: Boolean
- Default value: Not set.
app.configure('production|development', 'gate|connector', function(){
app.set('connectorConfig', {
connector: pomelo.connectors.hybridconnector,
heartbeat: 45,
timeout: 55, // Seconds, heartbeat timer + timeout timer
disconnectOnTimeout : true,
useDict: true,
useProtobuf: true
});
});
Useful when connectorConfig.useDict is true. It can only be applied to frontend servers.
- Desc: Absolute path of the dictionary file.
- Type: String.
- Default value: Not set.
app.configure('production|development', 'connector', function(){
app.set('connectorConfig', {
...
useDict: true
});
app.set('dictionaryConfig', {
dict: '/home/foo/config/dictionary.json'
});
});
Useful when connectorConfig.useProtobuf is true. It can only be applied to frontend servers.
- Desc: Absolute path of the server proto file.
- Type: String.
- Default value: Not set.
- Desc: Absolute path of the client proto file.
- Type: String.
- Default value: Not set.
app.configure('production|development', 'connector', function(){
app.set('connectorConfig', {
...
useProtobuf: true
});
app.set('protobufConfig', {
serverProtos: '/home/foo/config/serverProtos.json',
clientProtos: '/home/foo/config/clientProtos.json'
});
});
Config for frontend sessionService. It can only be applied to frontend servers.
- Desc: According to the doc, if set it to true, then it allows only one logged session for an user, when a new session is logging, the logged session will be kicked. But from the codes, if set it to true, the logged session is kept, and the new session is denied.
- Type: Boolean.
- Default value: Not set which will be evaluated as false.
app.configure('production|development', 'connector', function(){
app.set('sessionConfig', {
singleSession: true
});
});
Config for push scheduler. It can only be applied to frontend servers.
- Desc: Push message to clients every 'flushInterval' milliseconds.
- Type: Number.
- Default value: 20.
app.configure('production|development', 'connector', function(){
// app.set('pushSchedulerConfig', {
app.set('schedulerConfig', {
flushInterval: 10
});
});
Not implemented.
Config for channelService. It can be applied to all servers except master server.
- Desc: A string will be used to create object key.
- Type: String.
- Default value: Not set which will be evaluated as ''.
- Desc: An object to store channelService. Seems like redis or something else.
- Type: Object.
- Default value: Not set.
- Desc: A function which will be called when push messages to clients if set.
- Type: Function.
- Default value: Not set.
Config for servers. It can be applied to all servers except master server.
- Desc: This flag controls whether pomelo will reload handlers when they are modified.
- Type: Boolean.
- Default value: Not set which will be evaluated as false.
app.configure('production|development', 'connector', function(){
app.set('serverConfig', {
reloadHandlers: true
});
});
Config for monitor module. It should be applied to all servers including master server if you want to use this config.
- Desc: Used to enable/disable the watchdog function.
- Type: Boolean.
- Default value: Not set which will be evaluated as false.
app.configure('production|development', function(){
app.set('monitorConfig', {
closeWatcher: true
});
});