Skip to content
This repository was archived by the owner on Sep 25, 2023. It is now read-only.

Runtime Configurations

leopoldfreeman edited this page Apr 1, 2015 · 30 revisions

Here are the all runtime configurations of Pomelo.

1. masterConfig

This config can only be applied to master server.

authUser

  • Desc: The function to auth user.
  • Type: Function.
  • Default value: utils.defaultAuthUser from 'pomelo-admin'.

authServer

  • Desc: The function to auth server.
  • Type: Function.
  • Default value: utils.defaultAuthServerMaster from 'pomelo-admin'.

Example

app.configure('production|development', 'master', function(){
  app.set('masterConfig', {
    authUser: function () { ... },
    authServer: function () { ... }
  });
});

2. proxyConfig

The config affects the client of 'pomeo-rpc'. It can be applied to all servers.

bufferMsg

  • 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.

interval

  • Desc: See above. The unit is millisecond. Used when bufferMsg is true.
  • Type: Number.
  • Default value: 30.

Example

app.configure('production|development', function(){
  app.set('proxyConfig', {
    bufferMsg: true,
    interval: 20
  });
});

3. remoteConfig

The config affects the server of 'pomeo-rpc'. It can be applied to all servers.

bufferMsg

  • Same as proxyConfig.bufferMsg.

interval

  • Same as proxyConfig.interval.

Example

app.configure('production|development', function(){
  app.set('remoteConfig', {
    bufferMsg: true,
    interval: 20
  });
});

4. connectionConfig

This configration is not implemented.

5. connectorConfig

This config is for frontend servers.

encode

  • Desc: Function to encode data which will be sent over network.
  • Type: Function.
  • Default value: Provided by connector.

decode

  • Desc: Function to decode data received from network.
  • Type: Function.
  • Default value: Provided by connector.

useCrypto

  • Desc: If true, pomelo will use RSA to verify the integrity of the message sent by clients.
  • Type: Boolean.
  • Default value: Not set, which will be evaluated as false.

blacklistFun

  • Desc: Function to filter ipv4 address.
  • Type: Function.
  • Default value: Not set (Do not use this feature, use iptables to filter ips).

Here is one implementation:

function blacklistFun (cb) {
  var badIpList = ['192.168.1.1', '192.168.1.2'];
  cb(null, badIpList);
}

useCrypto

  • Desc: If true, pomelo will use RSA to verify the integrity of the message sent by clients.
  • Type: Boolean.
  • Default value: Not set, which will be evaluated as false.

useDict

  • Desc: Enable route compress or not. If true, pomelo will try to read dictionary from $APPBASE/config/dictionary.json. You can override this by provide dictionaryConfig. See below.
  • Type: Boolean.
  • Default value: Not set, which will be evaluated as false.

useProtobuf

  • 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 provide protobufConfig. See below.
  • Type: Boolean.
  • Default value: Not set, which will be evaluated as false.

connector

  • Desc: The type of connector.
  • Type: Object.
  • Default value: sioconnector.

heartbeat

  • Desc: The interval to send heartbeat packet. Unit is second.
  • Type: Number.
  • Default value: Not set.

disconnectOnTimeout

  • Desc: Disconnect the socket if not receive the heartbeat in time.
  • Type: Boolean.
  • Default value: Not set.

timeout

  • Desc: Seconds to receive heartbeat. Used when disconnectOnTimeout is true. Unit is second.
  • Type: Number.
  • Default value: Not set.

checkClient

  • Desc: Function will be called at handshake.
  • Type: Function.
  • Default value: Not set.

handshake

  • Desc: Handshake function.
  • Type: Function.
  • Default value: Not set.

Example

app.configure('production|development', 'gate|connector', function(){
  app.set('connectorConfig', {
    connector : pomelo.connectors.hybridconnector,                                                                                                                                                                            
    timeout: 55,    // Seconds, heartbeat timer + timeout timer
    disconnectOnTimeout : true,
    useDict: true,
    useProtobuf: true
  });
});
Clone this wiki locally