This is part of scalecube-js project, see more at https://github.com/scalecube/scalecube-js
Full documentation
This package provides a default cluster implementation for node-js. it uses SWIM protocol for discovering members in distributed environment.
import { joinCluster } from '@scalecube/cluster-nodejs';
const clusterOptions = {
seedAddress,
address,
itemsToPublish: [],
};
const cluster = joinCluster(clusterOptions);
// calling `getCurrentMembersData()`, will resolve with the distributed environment's latest state.
cluster.getCurrentMembersData().then(console.log);
// on subscribe to `listen$()`, we will start getting emits of the distributed environment's latest state.
cluster.listen$().subscribe(console.log);
// on calling `destroy()`, we will remove our metadata from the distributed environment.
// also, it stops the cluster from sharing/publishing metadata.
cluster.destroy().then(console.log);