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.

npm install etcd-grpc
INSTALL
IMPORT
SIG · ETCD-GRPC
E
etcd-grpc
databasejavascriptv0.6.2
harness data pending
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.

Etcd
import { Etcd } from 'etcd-grpc'
const Etcd = require('etcd-grpc')
Named export; CommonJS require gets the module object, not the class directly. Use destructuring.
getErrorKind
import { getErrorKind } from 'etcd-grpc'
import getErrorKind from 'etcd-grpc'
Named export; not default. Also note that ErrorKind enum is imported similarly.
ErrorKind
import { ErrorKind } from 'etcd-grpc'
const { ErrorKind } = require('etcd-grpc')
ErrorKind is a TypeScript enum, available as a named export. In CommonJS, destructure from require.
put
client.put({ key: Buffer.from('name'), value: Buffer.from('John') })
client.put({ key: 'name', value: 'John' })
key and value must be Buffer instances, not strings. Use Buffer.from() for encoding.

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 issues
gotchaKey and value parameters must be Buffer instances, not strings. Using strings will cause runtime errors.
fix
Always convert strings to Buffer: Buffer.from('key')
affects: >=0.0.0
gotchaThe error handling requires importing getErrorKind and ErrorKind; raw gRPC errors are not directly exported.
fix
Import { getErrorKind, ErrorKind } from 'etcd-grpc' and use getErrorKind(err) to classify errors.
affects: >=0.0.0
gotchaThe client does not automatically reconnect on connection failure; you must manually catch CONNECTION_FAILED errors and call client.reconnect().
fix
Wrap etcd calls in try-catch, check getErrorKind(err) === ErrorKind.CONNECTION_FAILED, then client.reconnect() and retry.
affects: >=0.0.0
breakingThe package is unmaintained since 2019 and may not support newer versions of etcd or Node.js.
fix
Consider using alternative clients like 'etcd3' or 'etcd-client' for up-to-date support.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: key must be a Buffer
Passing a string instead of a Buffer for the key or value parameter
fix
Use Buffer.from('mykey') for key and value fields.
getErrorKind is not a function
Incorrect import using default import or missing curly braces
fix
Use named import: import { getErrorKind } from 'etcd-grpc'
Error: 14 UNAVAILABLE: failed to connect to all addresses
etcd server is not running or unreachable
fix
Ensure etcd is running on the expected host:port (default localhost:2379).
Upgrade
Version history
0.6.2latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredRuntime dependency for gRPC functionality
@types/nodeoptionalTypeScript type definitions used in development
Agent activity
9 hits · last 30 days
node
8
Resources
etcd-grpc — npm install etcd-grpc · libregistry