1.0.1 • Published 5 years ago

@dadongicar/grpc-healthcheck v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

healthcheck

prettier

Node gRPC health check.

get started

  • install
npm i @dadongicar/grpc-healthcheck

example

  • server

    const grpc = require('grpc')
    const servers = require('@dadongicar/grpc-healthcheck')
    let port = 7000
    const server = new grpc.Server()
    const grpcHealthCheck = new servers.Health()
    server.addService(servers.HealthService, grpcHealthCheck)
    server.bind(`0.0.0.0:${port}`, grpc.ServerCredentials.createInsecure())
    console.info('Listening on http://localhost:7000')
    server.start()
  • client

    const grpc = require('grpc')
    const server = require('@dadongicar/grpc-healthcheck')
    const client = new server.HealthClient(
        'localhost:7000',
        grpc.credentials.createInsecure()
    )
    const statusReq = new server.SetStatusRequest()
    statusReq.setService('message.service')
    statusReq.setStatus(server.ServingStatus.SERVING)
    client.setStatus(statusReq, (err, res) => {
        if (err) throw err
        const req = new server.HealthCheckRequest()
        req.setService('message.service')
        client.check(req, (err, ress) => {
            if (err) throw err
            console.log('[HealthStatus]: ', ress.toObject())
        })
    })
1.0.1

5 years ago

1.0.0

5 years ago