From 4ad68a0d048edbb28803ac3e46d12b54173a5218 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Fri, 19 Nov 2021 20:39:44 +0800 Subject: [PATCH] fix: triple reflection --- pkg/common/service.go | 5 +++++ pkg/triple/dubbo3_server.go | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/common/service.go b/pkg/common/service.go index 2426c71..fbc0c1a 100644 --- a/pkg/common/service.go +++ b/pkg/common/service.go @@ -30,6 +30,11 @@ type TripleGrpcService interface { XXX_ServiceDesc() *grpc.ServiceDesc } +// TripleGrpcReflectService is gRPC service, used to check impl +type TripleGrpcReflectService interface { + SetGRPCServer(s *grpc.Server) +} + // TripleUnaryService is normal protocol service (except grpc service), should be implemented by users type TripleUnaryService interface { InvokeWithArgs(ctx context.Context, methodName string, arguments []interface{}) (interface{}, error) diff --git a/pkg/triple/dubbo3_server.go b/pkg/triple/dubbo3_server.go index 93f040e..76eafc0 100644 --- a/pkg/triple/dubbo3_server.go +++ b/pkg/triple/dubbo3_server.go @@ -34,7 +34,6 @@ import ( "github.com/dubbogo/grpc-go/encoding/msgpack" "github.com/dubbogo/grpc-go/encoding/proto_wrapper_api" "github.com/dubbogo/grpc-go/encoding/raw_proto" - perrors "github.com/pkg/errors" ) @@ -238,10 +237,13 @@ func (t *TripleServer) Start() { desc := grpcService.XXX_ServiceDesc() desc.ServiceName = key.(string) grpcServer.RegisterService(desc, value) - return true + } else { + desc := createGrpcDesc(key.(string), value.(common.TripleUnaryService)) + grpcServer.RegisterService(desc, value) + } + if key == "grpc.reflection.v1alpha.ServerReflection" { + grpcService.(common.TripleGrpcReflectService).SetGRPCServer(grpcServer) } - desc := createGrpcDesc(key.(string), value.(common.TripleUnaryService)) - grpcServer.RegisterService(desc, value) return true }) @@ -263,6 +265,9 @@ func (t *TripleServer) RefreshService() { desc := createGrpcDesc(key.(string), value.(common.TripleUnaryService)) grpcServer.RegisterService(desc, value) } + if key == "grpc.reflection.v1alpha.ServerReflection" { + grpcService.(common.TripleGrpcReflectService).SetGRPCServer(grpcServer) + } return true }) t.grpcServer.Stop()