Skip to content

Commit

Permalink
Think nil case
Browse files Browse the repository at this point in the history
  • Loading branch information
rerost committed Sep 1, 2024
1 parent 5dc3bb4 commit 7c5599a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions domain/grpcreflectiface/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func (c *clientImpl) ResolveService(serviceName string) (protoreflect.ServiceDes
}

var svcDescriptor protoreflect.ServiceDescriptor
if resp.GetFileDescriptorResponse() == nil {
return nil, nil
}
for _, fdProtoBytes := range resp.GetFileDescriptorResponse().FileDescriptorProto {
var fdProto descriptorpb.FileDescriptorProto

Expand Down
7 changes: 7 additions & 0 deletions domain/messagename/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package messagename

import (
"context"
"fmt"

"github.com/pkg/errors"
"github.com/rerost/giro/domain/grpcreflectiface"
Expand Down Expand Up @@ -34,6 +35,9 @@ func (mnr *messageNameResolverImpl) RequestMessageName(ctx context.Context, serv
if err != nil {
return "", errors.WithStack(err)
}
if md == nil {
return "", fmt.Errorf("Method notfound, serviceName: %v, methodName: %v", serviceName, methodName)
}

return MessageName(md.Input().FullName()), nil
}
Expand All @@ -52,6 +56,9 @@ func (mnr *messageNameResolverImpl) resolveMethodDescriptor(ctx context.Context,
if err != nil {
return nil, errors.WithStack(err)
}
if sd == nil {
return nil, nil
}

md := sd.Methods().ByName(protoreflect.FullName(methodName).Name())
if md == nil {
Expand Down
3 changes: 3 additions & 0 deletions domain/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ func (ss *serviceServiceImpl) Ls(ctx context.Context, serviceName *string, metho
if err != nil {
return nil, errors.WithStack(err)
}
if sd == nil {
return []Service{svc}, nil
}

for i := 0; i < sd.Methods().Len(); i++ {
md := sd.Methods().Get(i)
Expand Down

0 comments on commit 7c5599a

Please sign in to comment.