storage: move errors to better locations
Change-Id: Ia44570949a8f6bb50220dc838c5b6aa21e851a4d
This commit is contained in:
parent
ea4a9e61c3
commit
48256c91b5
@ -13,9 +13,11 @@ import (
|
||||
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
// ErrValueChanged is returned when the current value of the key does not match the oldValue in UpdateSegmentPieces.
|
||||
var ErrValueChanged = errs.Class("value changed")
|
||||
|
||||
// UpdateSegmentPieces contains arguments necessary for updating segment pieces.
|
||||
type UpdateSegmentPieces struct {
|
||||
StreamID uuid.UUID
|
||||
@ -103,7 +105,7 @@ func (db *DB) UpdateSegmentPieces(ctx context.Context, opts UpdateSegmentPieces)
|
||||
}
|
||||
|
||||
if !EqualAliasPieces(newPieces, resultPieces) {
|
||||
return storage.ErrValueChanged.New("segment remote_alias_pieces field was changed")
|
||||
return ErrValueChanged.New("segment remote_alias_pieces field was changed")
|
||||
}
|
||||
|
||||
mon.Meter("segment_update").Mark(1)
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/satellite/metabase"
|
||||
"storj.io/storj/satellite/metabase/metabasetest"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
func TestUpdateSegmentPieces(t *testing.T) {
|
||||
@ -257,7 +256,7 @@ func TestUpdateSegmentPieces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
ErrClass: &storage.ErrValueChanged,
|
||||
ErrClass: &metabase.ErrValueChanged,
|
||||
ErrText: "segment remote_alias_pieces field was changed",
|
||||
}.Check(ctx, t, db)
|
||||
|
||||
|
@ -9,3 +9,6 @@ import (
|
||||
|
||||
// Error is a standard error class for this package.
|
||||
var Error = errs.Class("repair queue")
|
||||
|
||||
// ErrEmpty is returned when attempting to Dequeue from an empty queue.
|
||||
var ErrEmpty = errs.Class("empty queue")
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"storj.io/storj/satellite/repair/queue"
|
||||
"storj.io/storj/satellite/satellitedb"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
func TestUntilEmpty(t *testing.T) {
|
||||
@ -45,7 +44,7 @@ func TestUntilEmpty(t *testing.T) {
|
||||
for {
|
||||
injuredSeg, err := repairQueue.Select(ctx)
|
||||
if err != nil {
|
||||
require.True(t, storage.ErrEmptyQueue.Has(err))
|
||||
require.True(t, queue.ErrEmpty.Has(err))
|
||||
break
|
||||
}
|
||||
idsMap[injuredSeg.StreamID]++
|
||||
@ -108,7 +107,7 @@ func TestOrder(t *testing.T) {
|
||||
|
||||
// segment should be considered "empty" now
|
||||
injuredSeg, err = repairQueue.Select(ctx)
|
||||
assert.True(t, storage.ErrEmptyQueue.Has(err))
|
||||
assert.True(t, queue.ErrEmpty.Has(err))
|
||||
assert.Nil(t, injuredSeg)
|
||||
})
|
||||
}
|
||||
@ -205,7 +204,7 @@ func testorderHealthyPieces(t *testing.T, connStr string) {
|
||||
|
||||
// queue should be considered "empty" now
|
||||
injuredSeg, err := repairQueue.Select(ctx)
|
||||
assert.True(t, storage.ErrEmptyQueue.Has(err))
|
||||
assert.True(t, queue.ErrEmpty.Has(err))
|
||||
assert.Nil(t, injuredSeg)
|
||||
}
|
||||
|
||||
@ -255,7 +254,7 @@ func TestOrderOverwrite(t *testing.T) {
|
||||
|
||||
// queue should be considered "empty" now
|
||||
injuredSeg, err := repairQueue.Select(ctx)
|
||||
assert.True(t, storage.ErrEmptyQueue.Has(err))
|
||||
assert.True(t, queue.ErrEmpty.Has(err))
|
||||
assert.Nil(t, injuredSeg)
|
||||
})
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/repair/queue"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
func TestInsertSelect(t *testing.T) {
|
||||
@ -135,7 +134,7 @@ func TestDequeueEmptyQueue(t *testing.T) {
|
||||
|
||||
_, err := q.Select(ctx)
|
||||
require.Error(t, err)
|
||||
require.True(t, storage.ErrEmptyQueue.Has(err), "error should of class EmptyQueue")
|
||||
require.True(t, queue.ErrEmpty.Has(err), "error should of class EmptyQueue")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/sync2"
|
||||
"storj.io/storj/satellite/repair/queue"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
// Error is a standard error class for this package.
|
||||
@ -105,7 +104,7 @@ func (service *Service) processWhileQueueHasItems(ctx context.Context) error {
|
||||
for {
|
||||
err := service.process(ctx)
|
||||
if err != nil {
|
||||
if storage.ErrEmptyQueue.Has(err) {
|
||||
if queue.ErrEmpty.Has(err) {
|
||||
return nil
|
||||
}
|
||||
service.log.Error("process", zap.Error(Error.Wrap(err)))
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"storj.io/storj/satellite/metabase"
|
||||
"storj.io/storj/satellite/repair/queue"
|
||||
"storj.io/storj/satellite/satellitedb/dbx"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
// RepairQueueSelectLimit defines how many items can be selected at the same time.
|
||||
@ -222,7 +221,7 @@ func (r *repairQueue) Select(ctx context.Context) (seg *queue.InjuredSegment, er
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, storage.ErrEmptyQueue.New("")
|
||||
return nil, queue.ErrEmpty.New("")
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
@ -22,15 +22,6 @@ var ErrKeyNotFound = errs.Class("key not found")
|
||||
// ErrEmptyKey is returned when an empty key is used in Put or in CompareAndSwap.
|
||||
var ErrEmptyKey = errs.Class("empty key")
|
||||
|
||||
// ErrValueChanged is returned when the current value of the key does not match the oldValue in CompareAndSwap.
|
||||
var ErrValueChanged = errs.Class("value changed")
|
||||
|
||||
// ErrEmptyQueue is returned when attempting to Dequeue from an empty queue.
|
||||
var ErrEmptyQueue = errs.Class("empty queue")
|
||||
|
||||
// ErrLimitExceeded is returned when request limit is exceeded.
|
||||
var ErrLimitExceeded = errs.Class("limit exceeded")
|
||||
|
||||
// Key is the type for the keys in a `KeyValueStore`.
|
||||
type Key []byte
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user