Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 933 Bytes

consul.md

File metadata and controls

39 lines (30 loc) · 933 Bytes

Consul Service

Manages Read operations for the Key-Value store and Service discovery of Consul.

Import the module

require('@aliceo2/web-ui').ConsulService

Create an instance

new ConsulService({hostname: HOST, port: PORT});

Where:

  • HOST - consul leader instance hostname
  • PORT - consul leader port number

Example

const ConsulService = require('@aliceo2/web-ui').ConsulService;
const consul = new ConsulService({hostname: 'localhost', port: '8080'});

/// Get Consul Leader Status
consul.getConsulLeaderStatus()
  .then(result => console.log(result))
  .catch(err => console.error(err));


/// Get Services
consul.getServices()
  .then(result => console.log(result))
  .catch(err => console.error(err));

/// Get only Keys by their prefix
consul.getKeysByPrefix('o2-keys')
  .then(result => console.log(result))
  .catch(err => console.error(err));