@afterlink/cluster
v2.0.3
Published
AfterLink Cluster — Multi-process clustering with Redis pub/sub
Readme
@afterlink/cluster
AfterLink multi-process clustering orchestrator with Redis and Redis Cluster pub/sub synchronization.
Installation
pnpm add @afterlink/clusterUsage
Single-node Redis Connection
const { createCluster } = require('@afterlink/cluster');
const Server = require('@afterlink/server');
createCluster({
workers: 4,
redis: {
host: 'localhost',
port: 6379
}
}, () => {
const server = new Server();
server.listen(4000);
});Redis Cluster Connection
You can connect your orchestrator to a Redis Cluster by providing an array of seed nodes:
const { createCluster } = require('@afterlink/cluster');
const Server = require('@afterlink/server');
createCluster({
workers: 4,
redis: {
nodes: [
{ host: '10.0.0.1', port: 7000 },
{ host: '10.0.0.2', port: 7001 },
{ host: '10.0.0.3', port: 7002 }
],
redisOptions: {
password: 'your-cluster-password'
}
}
}, () => {
const server = new Server();
server.listen(4000);
});