![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
nice-grpc-server-health
Advanced tools
Health Checking Protocol implementation for nice-grpc.
This package enables you to use tools like grpc-health-probe with your gRPC server.
npm install nice-grpc-server-health
For the simplest usage, just add the
Health
service implementation to your server. The server will be considered healthy
while it is able to accept requests.
import {createServer} from 'nice-grpc';
import {HealthDefinition, HealthServiceImpl} from 'nice-grpc-server-health';
const server = createServer();
server.add(HealthDefinition, HealthServiceImpl());
You can control the health state of the server or per-service with HealthState
object:
import {createServer} from 'nice-grpc';
import {
HealthDefinition,
HealthServiceImpl,
HealthState,
} from 'nice-grpc-server-health';
const server = createServer();
const healthState = HealthState();
server.add(HealthDefinition, HealthServiceImpl(healthState));
// Add our own service
server.add(MyService, myServiceImpl);
// Set the server status to `unhealthy`. The default server status is `healthy`.
healthState.setStatus('unhealthy');
// Set the `MyService` status to `unhealthy` by specifying fully-qualified name.
// The default service status is `unknown`.
healthState.setStatus('unhealthy', MyService.fullName);
// ...
healthState.setStatus('healthy');
healthState.setStatus('healthy', MyService.fullName);
This package also supports the Watch
method that is able to send real-time
updates of health statuses. Since the Watch
method returns infinite stream, it
is recommended to use the
terminator middleware:
import {createServer} from 'nice-grpc';
import {HealthDefinition, HealthServiceImpl} from 'nice-grpc-server-health';
import {TerminatorMiddleware} from 'nice-grpc-server-middleware-terminator';
const terminatorMiddleware = TerminatorMiddleware();
const server = createServer().use(terminatorMiddleware);
server.add(HealthDefinition, HealthServiceImpl());
await server.listen('0.0.0.0:8080');
// ... terminate middleware before shutdown:
terminatorMiddleware.terminate();
await server.shutdown();
FAQs
gRPC health checking protocol implementation for nice-grpc
The npm package nice-grpc-server-health receives a total of 7,291 weekly downloads. As such, nice-grpc-server-health popularity was classified as popular.
We found that nice-grpc-server-health demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.