forked from TrueCloudLab/frostfs-node
[#1969] local_object_storage: Simplify logic error construction
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
fcdbf5e509
commit
56de2f1363
17 changed files with 25 additions and 36 deletions
|
@ -1,12 +1,10 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
)
|
||||
|
||||
// ErrObjectIsExpired is returned when the requested object's
|
||||
// epoch is less than the current one. Such objects are considered
|
||||
// as removed and should not be returned from the Storage Engine.
|
||||
var ErrObjectIsExpired = logicerr.Wrap(errors.New("object is expired"))
|
||||
var ErrObjectIsExpired = logicerr.New("object is expired")
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
)
|
||||
|
||||
// ErrReadOnly MUST be returned for modifying operations when the storage was opened
|
||||
// in readonly mode.
|
||||
var ErrReadOnly = logicerr.Wrap(errors.New("opened as read-only"))
|
||||
var ErrReadOnly = logicerr.New("opened as read-only")
|
||||
|
||||
// ErrNoSpace MUST be returned when there is no space to put an object on the device.
|
||||
var ErrNoSpace = logicerr.Wrap(errors.New("no free space"))
|
||||
var ErrNoSpace = logicerr.New("no free space")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package blobstor
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
|
@ -12,7 +11,7 @@ import (
|
|||
|
||||
// ErrNoPlaceFound is returned when object can't be saved to any sub-storage component
|
||||
// because of the policy.
|
||||
var ErrNoPlaceFound = logicerr.Wrap(errors.New("couldn't find a place to store an object"))
|
||||
var ErrNoPlaceFound = logicerr.New("couldn't find a place to store an object")
|
||||
|
||||
// Put saves the object in BLOB storage.
|
||||
//
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package engine
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
@ -15,7 +14,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var errShardNotFound = logicerr.Wrap(errors.New("shard not found"))
|
||||
var errShardNotFound = logicerr.New("shard not found")
|
||||
|
||||
type hashedShard shardWrapper
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
// ErrDegradedMode is returned when metabase is in a degraded mode.
|
||||
var ErrDegradedMode = logicerr.Wrap(errors.New("metabase is in a degraded mode"))
|
||||
var ErrDegradedMode = logicerr.New("metabase is in a degraded mode")
|
||||
|
||||
// Open boltDB instance for metabase.
|
||||
func (db *DB) Open(readOnly bool) error {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
|
@ -25,7 +24,7 @@ type ExistsRes struct {
|
|||
exists bool
|
||||
}
|
||||
|
||||
var ErrLackSplitInfo = logicerr.Wrap(errors.New("no split info on parent object"))
|
||||
var ErrLackSplitInfo = logicerr.New("no split info on parent object")
|
||||
|
||||
// SetAddress is an Exists option to set object checked for existence.
|
||||
func (p *ExistsPrm) SetAddress(addr oid.Address) {
|
||||
|
|
|
@ -79,7 +79,7 @@ var errBreakBucketForEach = errors.New("bucket ForEach break")
|
|||
|
||||
// ErrLockObjectRemoval is returned when inhume operation is being
|
||||
// performed on lock object, and it is not a forced object removal.
|
||||
var ErrLockObjectRemoval = logicerr.Wrap(errors.New("lock object removal"))
|
||||
var ErrLockObjectRemoval = logicerr.New("lock object removal")
|
||||
|
||||
// Inhume marks objects as removed but not removes it from metabase.
|
||||
//
|
||||
|
|
|
@ -35,7 +35,7 @@ type ExpiredObjectHandler func(*ExpiredObject) error
|
|||
|
||||
// ErrInterruptIterator is returned by iteration handlers
|
||||
// as a "break" keyword.
|
||||
var ErrInterruptIterator = logicerr.Wrap(errors.New("iterator is interrupted"))
|
||||
var ErrInterruptIterator = logicerr.New("iterator is interrupted")
|
||||
|
||||
// IterateExpired iterates over all objects in DB which are out of date
|
||||
// relative to epoch. Locked objects are not included (do not confuse
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
|
@ -12,7 +10,7 @@ import (
|
|||
// ErrEndOfListing is returned from object listing with cursor
|
||||
// when storage can't return any more objects after provided
|
||||
// cursor. Use nil cursor object to start listing again.
|
||||
var ErrEndOfListing = logicerr.Wrap(errors.New("end of object listing"))
|
||||
var ErrEndOfListing = logicerr.New("end of object listing")
|
||||
|
||||
// Cursor is a type for continuous object listing.
|
||||
type Cursor struct {
|
||||
|
|
|
@ -2,7 +2,6 @@ package meta
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
|
@ -17,7 +16,7 @@ var versionKey = []byte("version")
|
|||
// ErrOutdatedVersion is returned on initializing
|
||||
// an existing metabase that is not compatible with
|
||||
// the current code version.
|
||||
var ErrOutdatedVersion = logicerr.Wrap(errors.New("invalid version, resynchronization is required"))
|
||||
var ErrOutdatedVersion = logicerr.New("invalid version, resynchronization is required")
|
||||
|
||||
func checkVersion(tx *bbolt.Tx, initialized bool) error {
|
||||
var knownVersion bool
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package pilorama
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
|
@ -68,7 +66,7 @@ type CIDDescriptor struct {
|
|||
|
||||
// ErrInvalidCIDDescriptor is returned when info about tne node position
|
||||
// in the container is invalid.
|
||||
var ErrInvalidCIDDescriptor = logicerr.Wrap(errors.New("cid descriptor is invalid"))
|
||||
var ErrInvalidCIDDescriptor = logicerr.New("cid descriptor is invalid")
|
||||
|
||||
func (d CIDDescriptor) checkValid() bool {
|
||||
return 0 <= d.Position && d.Position < d.Size
|
||||
|
|
|
@ -2,7 +2,6 @@ package shard
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
|
@ -47,7 +46,7 @@ func (r DumpRes) Count() int {
|
|||
return r.count
|
||||
}
|
||||
|
||||
var ErrMustBeReadOnly = logicerr.Wrap(errors.New("shard must be in read-only mode"))
|
||||
var ErrMustBeReadOnly = logicerr.New("shard must be in read-only mode")
|
||||
|
||||
// Dump dumps all objects from the shard to a file or stream.
|
||||
//
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package shard
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
)
|
||||
|
||||
// ErrReadOnlyMode is returned when it is impossible to apply operation
|
||||
// that changes shard's memory due to the "read-only" shard's mode.
|
||||
var ErrReadOnlyMode = logicerr.Wrap(errors.New("shard is in read-only mode"))
|
||||
var ErrReadOnlyMode = logicerr.New("shard is in read-only mode")
|
||||
|
||||
// ErrDegradedMode is returned when operation requiring metabase is executed in degraded mode.
|
||||
var ErrDegradedMode = logicerr.Wrap(errors.New("shard is in degraded mode"))
|
||||
var ErrDegradedMode = logicerr.New("shard is in degraded mode")
|
||||
|
||||
// SetMode sets mode of the shard.
|
||||
//
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
// ErrInvalidMagic is returned when dump format is invalid.
|
||||
var ErrInvalidMagic = logicerr.Wrap(errors.New("invalid magic"))
|
||||
var ErrInvalidMagic = logicerr.New("invalid magic")
|
||||
|
||||
// RestorePrm groups the parameters of Restore operation.
|
||||
type RestorePrm struct {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package shard
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||
cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
|
@ -11,7 +9,7 @@ import (
|
|||
var _ pilorama.Forest = (*Shard)(nil)
|
||||
|
||||
// ErrPiloramaDisabled is returned when pilorama was disabled in the configuration.
|
||||
var ErrPiloramaDisabled = logicerr.Wrap(errors.New("pilorama is disabled"))
|
||||
var ErrPiloramaDisabled = logicerr.New("pilorama is disabled")
|
||||
|
||||
// TreeMove implements the pilorama.Forest interface.
|
||||
func (s *Shard) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) (*pilorama.LogMove, error) {
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package logicerr
|
||||
|
||||
import "errors"
|
||||
|
||||
// Logical is a wrapper for logical errors.
|
||||
type Logical struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// New returns simple error with a provided error message.
|
||||
func New(msg string) Logical {
|
||||
return Wrap(errors.New(msg))
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e Logical) Error() string {
|
||||
return e.err.Error()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package writecache
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -10,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
// ErrReadOnly is returned when Put/Write is performed in a read-only mode.
|
||||
var ErrReadOnly = logicerr.Wrap(errors.New("write-cache is in read-only mode"))
|
||||
var ErrReadOnly = logicerr.New("write-cache is in read-only mode")
|
||||
|
||||
// SetMode sets write-cache mode of operation.
|
||||
// When shard is put in read-only mode all objects in memory are flushed to disk
|
||||
|
|
Loading…
Reference in a new issue