forked from jondubois/iogrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbroker.js
22 lines (19 loc) · 1.03 KB
/
broker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var scClusterBrokerClient = require('sc-cluster-broker-client');
module.exports.run = function (broker) {
console.log(' >> Broker PID:', process.pid);
// This is defined in server.js (taken from environment variable SC_CLUSTER_STATE_SERVER_HOST).
// If this property is defined, the broker will try to attach itself to the SC cluster for
// automatic horizontal scalability.
// This is mostly intended for the Kubernetes deployment of SocketCluster - In this case,
// The clustering/sharding all happens automatically.
if (broker.options.clusterStateServerHost) {
scClusterBrokerClient.attach(broker, {
stateServerHost: broker.options.clusterStateServerHost,
stateServerPort: broker.options.clusterStateServerPort,
authKey: broker.options.clusterAuthKey,
stateServerConnectTimeout: broker.options.clusterStateServerConnectTimeout,
stateServerAckTimeout: broker.options.clusterStateServerAckTimeout,
stateServerReconnectRandomness: broker.options.clusterStateServerReconnectRandomness
});
}
};