1.0.0 • Published 6 years ago

node-cluster-client v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago
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)