frostfs-node/pkg/network/transport/container/grpc/delete.go

33 lines
822 B
Go
Raw Normal View History

package container
import (
"context"
"github.com/nspcc-dev/neofs-api-go/container"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (s cnrService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
// check healthiness
if err := s.healthy.Healthy(); err != nil {
return nil, errors.Wrap(err, "try again later")
}
// verify request structure
if err := requestVerifyFunc(req); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
2020-07-24 13:54:03 +00:00
// remove container from storage
if err := s.cnrStore.Delete(req.GetCID()); err != nil {
return nil, status.Error(
codes.Aborted,
2020-07-24 13:54:03 +00:00
errors.Wrap(err, "could not remove container from storage").Error(),
)
}
return new(container.DeleteResponse), nil
}