reduce ptypes.Empty creation by defining it in as a var

Signed-off-by: Jin Dong <djdongjin95@gmail.com>
This commit is contained in:
Jin Dong
2024-08-29 17:27:47 -07:00
parent dacde84372
commit 9c34005724
7 changed files with 26 additions and 14 deletions

View File

@@ -36,6 +36,8 @@ import (
"google.golang.org/grpc"
)
var empty = &ptypes.Empty{}
func init() {
registry.Register(&plugin.Registration{
Type: plugins.GRPCPlugin,
@@ -84,7 +86,7 @@ func (s *service) Publish(ctx context.Context, r *api.PublishRequest) (*ptypes.E
return nil, errdefs.ToGRPC(err)
}
return &ptypes.Empty{}, nil
return empty, nil
}
func (s *service) Forward(ctx context.Context, r *api.ForwardRequest) (*ptypes.Empty, error) {
@@ -92,7 +94,7 @@ func (s *service) Forward(ctx context.Context, r *api.ForwardRequest) (*ptypes.E
return nil, errdefs.ToGRPC(err)
}
return &ptypes.Empty{}, nil
return empty, nil
}
func (s *service) Subscribe(req *api.SubscribeRequest, srv api.Events_SubscribeServer) error {

View File

@@ -37,7 +37,7 @@ func (s *ttrpcService) Forward(ctx context.Context, r *api.ForwardRequest) (*pty
return nil, errdefs.ToGRPC(err)
}
return &ptypes.Empty{}, nil
return empty, nil
}
func fromTProto(env *types.Envelope) *events.Envelope {