-
Notifications
You must be signed in to change notification settings - Fork 0
/
broker.js
29 lines (25 loc) · 1.22 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
23
24
25
26
27
28
29
var SCBroker = require('socketcluster/scbroker');
var scClusterBrokerClient = require('scc-broker-client');
class Broker extends SCBroker {
run() {
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 (this.options.clusterStateServerHost) {
scClusterBrokerClient.attach(this, {
stateServerHost: this.options.clusterStateServerHost,
stateServerPort: this.options.clusterStateServerPort,
mappingEngine: this.options.clusterMappingEngine,
clientPoolSize: this.options.clusterClientPoolSize,
authKey: this.options.clusterAuthKey,
stateServerConnectTimeout: this.options.clusterStateServerConnectTimeout,
stateServerAckTimeout: this.options.clusterStateServerAckTimeout,
stateServerReconnectRandomness: this.options.clusterStateServerReconnectRandomness
});
}
}
}
new Broker();