1.0.0 • Published 8 years ago
node-cluster-client
Licence
ISC
Version
1.0.0
Deps
1
Size
20 kB
Vulns
0
Weekly
0
import * as os from 'os'
import * as cluster from 'cluster'
import ClusterClient from 'cluster-client'
const forkNum = os.cpus().length <= 3 ? 3 : os.cpus().length
if (cluster.isMaster) {
ClusterClient.initMaster()
for (let i = 0; i < forkNum; i++) {
cluster.fork()
}
...
} else {
ClusterClient.initWorker()
...
}
import Redis from 'ioredis'
// will return the real instance in the leader process
// and the empty object which proxy to the real instance via node-ipc
const myClusterRedis = new ClusterClient(Redis).create(option)