🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bletcd

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bletcd

A minimalistic etcd client

2.2.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

bletcd - The Bloglovin' etcd client

Bletcd is a minimalistic etcd client with convenient functionality for watching for changes.

Usage

var client = bletcd({
  url: 'http://127.0.0.1:4001',
});

var watcher = client.watcher('test/other-key');
watcher.on('error', function(err) {
  console.error('Watch error:', err);
  watcher.stop();
});
watcher.on('change', function(op) {
  console.log('Notified of change:', op);
});

client.put('test/other-key', 'a-value', function(err, response) {
  if (err) {
    console.error('Failed to write value', err);
    watcher.stop();
    return;
  }
  console.log('Wrote a value to etcd');

  client.get('test/other-key', function(err, response) {
    if (err) {
      console.error('Failed to fetch value', err);
    }
    else {
      console.log('Successfully fetched the key value:', response.node.value);
    }

    client.delete('test/other-key', function(err) {
      if (err) {
        console.error('Failed to delete value:', err);
      }
      else {
        console.log('Successfully deleted value');
      }
      watcher.stop();
    });
  });
});

Output:

Notified of change: { action: 'set',
  node:
   { key: '/test/other-key',
     value: 'a-value',
     modifiedIndex: 537,
     createdIndex: 537 } }
Wrote a value to etcd
Successfully fetched the key value: a-value
Notified of change: { action: 'delete',
  node: { key: '/test/other-key', modifiedIndex: 538, createdIndex: 537 },
  prevNode:
   { key: '/test/other-key',
     value: 'a-value',
     modifiedIndex: 537,
     createdIndex: 537 } }
Successfully deleted value

Keywords

etcd

FAQs

Package last updated on 14 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts