Registry / devops / watchdog-grpc-sdk

watchdog-grpc-sdk

JSON →
library1.0.7jsnpmunverified

TypeScript/Node.js client SDK for interacting with the Watchdog gRPC service — a microservice monitoring and service discovery system. Current version 1.0.7, requires Node >= 14, ships full TypeScript type definitions, provides a promise-based API built on @grpc/grpc-js. Differentiators: auto-generated from protobuf schemas ensuring server-client sync, built-in timeout handling, and no external runtime dependencies beyond gRPC.

npm install watchdog-grpc-sdk
INSTALL
IMPORT
SIG · WATCHDOG-GRPC-SDK
W
watchdog-grpc-sdk
devopsjavascriptv1.0.7
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.

WatchdogClient
import { WatchdogClient } from 'watchdog-grpc-sdk'
const WatchdogClient = require('watchdog-grpc-sdk')
Named export – require will not work as the package is ESM-only in v1.0.0+.
ServiceType
import { ServiceType } from 'watchdog-grpc-sdk'
const ServiceType = require('watchdog-grpc-sdk').ServiceType
Named export, not a default. Ensure you use destructured import.
WatchdogClientOptions
import type { WatchdogClientOptions } from 'watchdog-grpc-sdk'
import { WatchdogClientOptions } from 'watchdog-grpc-sdk'
TypeScript type import to avoid runtime overhead. Use import type.

Creates a WatchdogClient, checks health, registers an HTTP service, lists all services, then closes the connection.

import { WatchdogClient, ServiceType } from 'watchdog-grpc-sdk'; async function main() { const client = new WatchdogClient({ host: process.env.WATCHDOG_HOST ?? 'localhost', port: Number(process.env.WATCHDOG_PORT ?? '50051'), }); try { const health = await client.getHealth(); console.log('Health:', health.status); const registration = await client.registerService({ name: 'my-service', endpoint: 'http://localhost:3000', type: ServiceType.SERVICE_TYPE_HTTP, }); console.log('Service registered:', registration.serviceId); const services = await client.listServices(); console.log('Services:', services.length); } finally { client.close(); } } main().catch(console.error);
Debug
Known issues
gotchaEager connection: The client connects immediately on construction; if the Watchdog server is unreachable, the constructor will throw.
fix
Wrap the new WatchdogClient() call in a try-catch or use a factory that defers connection.
affects: >=1.0.0
deprecatedServiceInfo#getType() returns a numeric enum value; avoid direct comparison to numbers, use the ServiceType enum.
fix
Compare service.getType() === ServiceType.SERVICE_TYPE_HTTP instead of comparing to raw numbers.
affects: >=1.0.0
gotchaDefault credentials are insecure (grpc.credentials.createInsecure()). For production, you must pass credentials with SSL/TLS.
fix
import * as grpc from '@grpc/grpc-js'; new WatchdogClient({..., credentials: grpc.credentials.createSsl()});
affects: >=1.0.0
gotchaThe client.close() method must be called to release gRPC resources; failing to do so can cause resource leaks.
fix
Call client.close() in a finally block after all operations complete.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: WatchdogClient is not a constructor
Using import { WatchdogClient } from 'watchdog-grpc-sdk' in a CommonJS environment that does not support ESM interop or using require incorrectly.
fix
Ensure your project is configured for ESM (type: module in package.json, or use .mjs extension). If using CommonJS, switch to dynamic import: const { WatchdogClient } = await import('watchdog-grpc-sdk');
Error: 14 UNAVAILABLE: failed to connect to all addresses
The Watchdog gRPC server is not running or unreachable at the configured host:port.
fix
Verify the WATCHDOG_HOST and WATCHDOG_PORT environment variables or constructor options point to a running instance. Check network connectivity and firewall rules.
TypeError: service.getType is not a function
Treating listServices() return items as plain objects instead of ServiceInfo protobuf message instances.
fix
Access properties using getter methods: service.getId(), service.getName(), service.getEndpoint(), service.getType(), service.getStatus(). Do not use dot properties like service.id or service.name.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
watchdog-grpc-sdk — npm install watchdog-grpc-sdk · libregistry