| runme |
|
|---|
In gRPC, a client application can directly call a method on a server application on a different machine as if it were a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.
Small gRPC server made in go that will expose CPU usage metrics of its host machine (either one shot or streamed)
Blazor SSR app that will connect to the gRPC server and display the CPU usage metrics to the client browsers
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3# Generate Go interface
protoc -I proto/ --go_out gomonitor --go-grpc_out gomonitor proto/MonitoringService.proto
# Generate .NET interface
# Nothing to do, it's taken care automatically by grpc tool at build time# to build
make build# To start
make start
Then to go http://localhost:5000/# To stop
make stop# to clean
make clean- Go: Implement proper flow control and context management for the streaming to properly terminate the connections (instead of leaving gorouting forever)
See https://apisix.apache.org/blog/2021/12/30/apisix-proxy-grpc-service/