Socket
Book a DemoInstallSign in
Socket

etcd-rpc

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

etcd-rpc

Node library to access etcd's gRPC API.

1.0.2
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

node-etcd-rpc

This module loads etcd's rpc.proto file so that you can access the gRPC API from Node. More importantly, it brings together all the other .proto files necessary to load it.

You can use this module as a client to etcd, but you will probably want to wrap some code around it for more functionality (e.g. failover to other server instances).

Usage

npm install etcd-rpc grpc

Example client:

const grpc = require('grpc');
const etcd = require('etcd-rpc');

const client = new etcd.KV('etcd.server.hostname:2379', grpc.credentials.createInsecure());

client.put({
    key: new Buffer('foo'),
    value: new Buffer('foofoo'),
}, function (err) {
    if (err) {
        throw err;
    }
});

client.range({
    key: new Buffer('foo'),
}, function (err, res) {
    if (err) {
        throw err;
    }

    res.kvs.forEach(function (o) {
        console.log(o.key.toString(), '->', o.value.toString());
    });
});

Example watcher client:

const grpc = require('grpc');
const etcd = require('etcd-rpc');

const client = new etcd.Watch('etcd.server.hostname:2379', grpc.credentials.createInsecure());
const stream = client.watch();

stream.on('data', function (data) {
    const id = data.watch_id;

    console.log('Created:', data);
    stream.removeAllListeners('data');

    stream.on('data', function (data) {
        data.events.forEach(function (ev) {
            console.log([ev.type, ev.kv.key.toString(), ev.kv.value.toString()]);
        });
    });

    setTimeout(function() {
        stream.on('data', function (data) {
            console.log('Cancelled:', data);
            stream.end();
        });

        stream.write({ cancel_request: { watch_id: id } });
    }, 10000);
});

stream.on('error', function (err) {
    throw err;
});

const ALL = new Buffer('\0');

stream.write({ create_request: { key: ALL, range_end: ALL } });

See rpc.proto for more information.

Keywords

etcd

FAQs

Package last updated on 31 Oct 2017

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.