Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.28 KB

README.md

File metadata and controls

34 lines (23 loc) · 1.28 KB

Join the chat at https://gitter.im/scalecube-js/Lobby

This is part of scalecube-js project, see more at https://github.com/scalecube/scalecube-js
Full documentation

Cluster-nodejs

This package provides a default cluster implementation for node-js. it uses SWIM protocol for discovering members in distributed environment.

Basic Usage

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);