You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/microservices/grpc.md
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -377,6 +377,42 @@ Nest supports GRPC stream handlers in two possible ways:
377
377
378
378
<app-banner-enterprise></app-banner-enterprise>
379
379
380
+
#### Health checks
381
+
382
+
When running a gRPC application in an orchestrator such a Kubernetes, you may need to know if it is running and in a healthy state. The [gRPC Health Check specification](https://grpc.io/docs/guides/health-checking/) is a standard that allow gRPC clients to expose their health status to allow the orchestrator to act accordingly.
383
+
384
+
To add gRPC health check support, first install the [grpc-node](https://github.com/grpc/grpc-node/tree/master/packages/grpc-health-check) package:
385
+
386
+
```bash
387
+
$ npm i --save grpc-health-check
388
+
```
389
+
390
+
Then it can be hooked into the gRPC service using the `onLoadPackageDefinition` hook in your gRPC server options, as follows. Note that the `protoPath` needs to have both the health check and the hero package.
> info **Hint** The [gRPC health probe](https://github.com/grpc-ecosystem/grpc-health-probe) is a useful CLI to test gRPC health checks in a containerized environment.
415
+
380
416
#### Streaming sample
381
417
382
418
Let's define a new sample gRPC service called `HelloService`. The `hello.proto` file is structured using <ahref="https://developers.google.com/protocol-buffers">protocol buffers</a>. Here's what it looks like:
0 commit comments