npm.io
0.2.11 • Published 5 years ago

@scalecube/scalecube-discovery

Licence
MIT
Version
0.2.11
Deps
3
Size
25 kB
Vulns
0
Weekly
0

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

Discovery

This package provides a default discovery implementation. it is intended to publish and discover any data in a distributed environment.

Basic Usage

import { createDiscovery } from '@scalecube/scalecube-discovery';

const discoveryConfig = {
  seedAddress,
  address,
  itemsToPublish: [],
};

const discovery = createDiscovery(discoveryConfig);

// on subscribe to `discoveredItems$()`, we will start getting emits of the distributed environment's latest state.
discovery.discoveredItems$().subscribe(console.log); 


// on calling `destroy()`, we will remove our metadata from the distributed environment. 
// also, it stops the discovery from sharing/publishing metadata.
discovery.destroy().then(console.log);