From d0a883c85d792e31388617b976ac0a940b08b65a Mon Sep 17 00:00:00 2001 From: Amit Zafran Date: Thu, 12 Sep 2024 14:18:15 +0300 Subject: [PATCH] feat: GRPC health (#1690) * grpc_health_v1 * consumer health server * a test commit, can be reverted if nessesary * rm toolchain * testify * Revert "grpc_health_v1" This reverts commit 1769d61d9c64a3269241cd72df2632d9c4a22d2a. * Reapply "grpc_health_v1" This reverts commit 9086a5cc000de34e894b19d761fef814c5eddfb9. * Revert "a test commit, can be reverted if nessesary" This reverts commit 659b341b26c7b81617a302924ed24b0db504df78. * remove health for provider --- protocol/chainlib/grpcproxy/grpcproxy.go | 3 +++ protocol/rpcprovider/provider_listener.go | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/protocol/chainlib/grpcproxy/grpcproxy.go b/protocol/chainlib/grpcproxy/grpcproxy.go index e5a06dcf3e..7ec2ec0d2c 100644 --- a/protocol/chainlib/grpcproxy/grpcproxy.go +++ b/protocol/chainlib/grpcproxy/grpcproxy.go @@ -13,6 +13,8 @@ import ( "golang.org/x/net/http2/h2c" "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/health" + "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -28,6 +30,7 @@ type HealthReporter interface { func NewGRPCProxy(cb ProxyCallBack, healthCheckPath string, cmdFlags common.ConsumerCmdFlags, healthReporter HealthReporter) (*grpc.Server, *http.Server, error) { serverReceiveMaxMessageSize := grpc.MaxRecvMsgSize(MaxCallRecvMsgSize) // setting receive size to 32mb instead of 4mb default s := grpc.NewServer(grpc.UnknownServiceHandler(makeProxyFunc(cb)), grpc.ForceServerCodec(RawBytesCodec{}), serverReceiveMaxMessageSize) + grpc_health_v1.RegisterHealthServer(s, health.NewServer()) wrappedServer := grpcweb.WrapServer(s) handler := func(resp http.ResponseWriter, req *http.Request) { // Set CORS headers diff --git a/protocol/rpcprovider/provider_listener.go b/protocol/rpcprovider/provider_listener.go index 30eb0cda62..a0f0830523 100644 --- a/protocol/rpcprovider/provider_listener.go +++ b/protocol/rpcprovider/provider_listener.go @@ -67,7 +67,6 @@ func NewProviderListener(ctx context.Context, networkAddress lavasession.Network grpc.MaxRecvMsgSize(1024 * 1024 * 32), // setting receive size to 32mb instead of 4mb default } grpcServer := grpc.NewServer(opts...) - wrappedServer := grpcweb.WrapServer(grpcServer) handler := func(resp http.ResponseWriter, req *http.Request) { // Set CORS headers