This repository demonstrates how to set up a simple gRPC server with a health check service and an HTTP server that triggers the gRPC health check when accessed.
The project is structured as follows:
cmd/client/main.go: The main entry point for the client application.internal/services/health_check: Contains the gRPC service definition and implementation for the health check.internal/servers/httpSrv/httpSrv.go: Contains the HTTP server setup.internal/handlers/healthCheckHandler.go: Contains the HTTP handler for triggering the gRPC health check.
- Go (version 1.18 or higher)
- Protocol Buffers Compiler (
protoc) - gRPC Go plugins
ps : Make sure port 9000 and 8080 are available
First Generate the gRPC code (if not already generated):
make build-protosAfter This you can run project below commands
make build-and-serve-server platform=linuxOR
make build-and-serve-client platform=darwinYou can also run the server directly without build :
make run-serverfor client: ps : make sure the 9000
make run-clientTo trigger the health check, access the following URL in your browser or using a tool like curl:
curl http://localhost:8080/healthIf the gRPC server is running and healthy, you should receive a response:
{"status":"ok","message":"Service is healthy"}