156ba85326
If an object has not been marked for removal by the GC in the current epoch yet but has already expired, respond with `ErrObjectNotFound` api status. Also, optimize shard iteration: a node must stop any iteration if the object is found but gonna be removed soon. All the checks are performed by the Metabase. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
32 lines
973 B
Go
32 lines
973 B
Go
package shard
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
|
)
|
|
|
|
// IsErrNotFound checks if error returned by Shard Get/Head/GetRange method
|
|
// corresponds to missing object.
|
|
func IsErrNotFound(err error) bool {
|
|
return errors.As(err, new(apistatus.ObjectNotFound))
|
|
}
|
|
|
|
// IsErrRemoved checks if error returned by Shard Exists/Get/Head/GetRange method
|
|
// corresponds to removed object.
|
|
func IsErrRemoved(err error) bool {
|
|
return errors.As(err, new(apistatus.ObjectAlreadyRemoved))
|
|
}
|
|
|
|
// IsErrOutOfRange checks if an error returned by Shard GetRange method
|
|
// corresponds to exceeding the object bounds.
|
|
func IsErrOutOfRange(err error) bool {
|
|
return errors.As(err, new(apistatus.ObjectOutOfRange))
|
|
}
|
|
|
|
// IsErrObjectExpired checks if an error returned by Shard corresponds to
|
|
// expired object.
|
|
func IsErrObjectExpired(err error) bool {
|
|
return errors.Is(err, object.ErrObjectIsExpired)
|
|
}
|