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

@@ -30,6 +30,8 @@ import (
"google.golang.org/grpc"
)
var empty = &ptypes.Empty{}
func init() {
registry.Register(&plugin.Registration{
Type: plugins.GRPCPlugin,
@@ -87,7 +89,7 @@ func (s *service) Delete(ctx context.Context, r *api.DeleteRequest) (*ptypes.Emp
}, opts...); err != nil {
return nil, errdefs.ToGRPC(err)
}
return &ptypes.Empty{}, nil
return empty, nil
}
func (s *service) List(ctx context.Context, r *api.ListRequest) (*api.ListResponse, error) {
@@ -117,7 +119,7 @@ func (s *service) AddResource(ctx context.Context, r *api.AddResourceRequest) (*
}); err != nil {
return nil, errdefs.ToGRPC(err)
}
return &ptypes.Empty{}, nil
return empty, nil
}
func (s *service) DeleteResource(ctx context.Context, r *api.DeleteResourceRequest) (*ptypes.Empty, error) {
@@ -131,7 +133,7 @@ func (s *service) DeleteResource(ctx context.Context, r *api.DeleteResourceReque
}); err != nil {
return nil, errdefs.ToGRPC(err)
}
return &ptypes.Empty{}, nil
return empty, nil
}
func (s *service) ListResources(ctx context.Context, r *api.ListResourcesRequest) (*api.ListResourcesResponse, error) {