Registry / database / etcd-grpc

etcd-grpc

JSON →
library0.6.2jsnpmunverified

A gRPC based etcd client for NodeJS targeting etcd V3, version 0.6.2. Provides a high-performance, promisified gRPC client with TypeScript support. Key differentiators include unified API across multiple etcd V3 services, automatic reconnection, and error handling with specific error kinds. The library covers KV, Watch, Lease, Cluster, and Maintenance services. Note: The package is relatively stable but has not seen recent updates (last release in 2019). It relies on the `@grpc/grpc-js` package transitively. Compared to `etcd3`, this library uses raw gRPC without a balance-rpc wrapper, and requires manual handling of byte buffers for keys and values.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Named export; CommonJS require gets the module object, not the class directly. Use destructuring.

import { Etcd } from 'etcd-grpc'

Named export; not default. Also note that ErrorKind enum is imported similarly.

import { getErrorKind } from 'etcd-grpc'

ErrorKind is a TypeScript enum, available as a named export. In CommonJS, destructure from require.

import { ErrorKind } from 'etcd-grpc'

key and value must be Buffer instances, not strings. Use Buffer.from() for encoding.

client.put({ key: Buffer.from('name'), value: Buffer.from('John') })

Shows initialization, put, range, and error handling with reconnect for an etcd-grpc client.

import { Etcd, getErrorKind, ErrorKind } from 'etcd-grpc'; const client = new Etcd(); async function main() { try { // Put a key-value pair await client.put({ key: Buffer.from('name'), value: Buffer.from('John') }); console.log('Put succeeded'); // Get the key const res = await client.range({ key: Buffer.from('name') }); console.log('Value:', res.kvs[0].value.toString()); } catch (err) { const kind = getErrorKind(err); if (kind === ErrorKind.CONNECTION_FAILED) { console.log('Connection failed, reconnecting...'); client.reconnect(); // retry logic } else { console.error('Error:', err); } } } main();
Debug
Known footguns
gotchaKey and value parameters must be Buffer instances, not strings. Using strings will cause runtime errors.
gotchaThe error handling requires importing getErrorKind and ErrorKind; raw gRPC errors are not directly exported.
gotchaThe client does not automatically reconnect on connection failure; you must manually catch CONNECTION_FAILED errors and call client.reconnect().
breakingThe package is unmaintained since 2019 and may not support newer versions of etcd or Node.js.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
mj12bot
1
Resources