How to use the grpc-health-check.Implementation function in grpc-health-check

To help you get started, we’ve selected a few grpc-health-check examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleCloudPlatform / esp-v2 / tests / endpoints / bookstore_grpc / grpc_server.js View on Github external
server.addService(bookstore_proto.Bookstore.service, {
    ListShelves: testDecorator(listShelves),
    CreateShelf: testDecorator(createShelf),
    GetShelf: testDecorator(getShelf),
    DeleteShelf: testDecorator(deleteShelf),
    ListBooks: testDecorator(listBooks),
    CreateBook: testDecorator(createBook),
    GetBook: testDecorator(getBook),
    DeleteBook: testDecorator(deleteBook),
  });

  // Health service following standard protocol
  const statusMap = {
    "": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.SERVING,
  };
  let healthImpl = new health.Implementation(statusMap);
  server.addService(health.service, healthImpl);

  if (process.argv.length >= 3) {
    PORT = parseInt(process.argv[2], 10);
    if (isNaN(PORT) || PORT < 1024 || PORT > 65535) {
      console.log(`port ${process.argv[2]} should be integer between 1024-65535`);
      process.exit(1);
    }
  }

  console.log(`GRPC Bookstore server binding to port ${PORT}`);
  server.bindAsync(`0.0.0.0:${PORT}`, grpc.ServerCredentials.createInsecure(), function (error, actualPort) {
    if (error) {
      console.log(error);
      return;
    }

grpc-health-check

Health check client and service for use with gRPC-node

Apache-2.0
Latest version published 3 months ago

Package Health Score

95 / 100
Full package analysis

Similar packages