frostfs-node/pkg/network/transport/container/grpc/delete.go
Stanislav Bogatyrev b7b5079934 Add Inner Ring code
2020-07-24 17:07:37 +03:00

32 lines
822 B
Go

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())
}
// remove container from storage
if err := s.cnrStore.Delete(req.GetCID()); err != nil {
return nil, status.Error(
codes.Aborted,
errors.Wrap(err, "could not remove container from storage").Error(),
)
}
return new(container.DeleteResponse), nil
}