Skip to content

Commit

Permalink
fix: triple reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceLiZhixin committed Nov 19, 2021
1 parent 2c8648a commit 4ad68a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pkg/common/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions pkg/triple/dubbo3_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
})

Expand All @@ -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()
Expand Down

0 comments on commit 4ad68a0

Please sign in to comment.