[#1559] metabase: Use Set prefix for parameter setting

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-07-12 17:59:37 +03:00 committed by fyrchik
parent f58234aa2f
commit 34d319fed2
32 changed files with 150 additions and 181 deletions

View file

@ -52,7 +52,7 @@ func TestReset(t *testing.T) {
func metaExists(db *meta.DB, addr oid.Address) (bool, error) { func metaExists(db *meta.DB, addr oid.Address) (bool, error) {
var existsPrm meta.ExistsPrm var existsPrm meta.ExistsPrm
existsPrm.WithAddress(addr) existsPrm.SetAddress(addr)
res, err := db.Exists(existsPrm) res, err := db.Exists(existsPrm)
return res.Exists(), err return res.Exists(), err

View file

@ -21,13 +21,11 @@ type DeletePrm struct {
// DeleteRes groups the resulting values of Delete operation. // DeleteRes groups the resulting values of Delete operation.
type DeleteRes struct{} type DeleteRes struct{}
// WithAddresses is a Delete option to set the addresses of the objects to delete. // SetAddresses is a Delete option to set the addresses of the objects to delete.
// //
// Option is required. // Option is required.
func (p *DeletePrm) WithAddresses(addrs ...oid.Address) { func (p *DeletePrm) SetAddresses(addrs ...oid.Address) {
if p != nil { p.addrs = addrs
p.addrs = addrs
}
} }
type referenceNumber struct { type referenceNumber struct {

View file

@ -120,7 +120,7 @@ func TestGraveOnlyDelete(t *testing.T) {
func metaDelete(db *meta.DB, addrs ...oid.Address) error { func metaDelete(db *meta.DB, addrs ...oid.Address) error {
var deletePrm meta.DeletePrm var deletePrm meta.DeletePrm
deletePrm.WithAddresses(addrs...) deletePrm.SetAddresses(addrs...)
_, err := db.Delete(deletePrm) _, err := db.Delete(deletePrm)
return err return err

View file

@ -23,11 +23,9 @@ type ExistsRes struct {
var ErrLackSplitInfo = errors.New("no split info on parent object") var ErrLackSplitInfo = errors.New("no split info on parent object")
// WithAddress is an Exists option to set object checked for existence. // SetAddress is an Exists option to set object checked for existence.
func (p *ExistsPrm) WithAddress(addr oid.Address) { func (p *ExistsPrm) SetAddress(addr oid.Address) {
if p != nil { p.addr = addr
p.addr = addr
}
} }
// Exists returns the fact that the object is in the metabase. // Exists returns the fact that the object is in the metabase.

View file

@ -21,22 +21,18 @@ type GetRes struct {
hdr *objectSDK.Object hdr *objectSDK.Object
} }
// WithAddress is a Get option to set the address of the requested object. // SetAddress is a Get option to set the address of the requested object.
// //
// Option is required. // Option is required.
func (p *GetPrm) WithAddress(addr oid.Address) { func (p *GetPrm) SetAddress(addr oid.Address) {
if p != nil { p.addr = addr
p.addr = addr
}
} }
// WithRaw is a Get option to set raw flag value. If flag is unset, then Get // SetRaw is a Get option to set raw flag value. If flag is unset, then Get
// returns header of virtual object, otherwise it returns SplitInfo of virtual // returns header of virtual object, otherwise it returns SplitInfo of virtual
// object. // object.
func (p *GetPrm) WithRaw(raw bool) { func (p *GetPrm) SetRaw(raw bool) {
if p != nil { p.raw = raw
p.raw = raw
}
} }
// Header returns the requested object header. // Header returns the requested object header.

View file

@ -128,7 +128,7 @@ func TestDB_Get(t *testing.T) {
obj = oidtest.Address() obj = oidtest.Address()
var prm meta.InhumePrm var prm meta.InhumePrm
prm.WithAddresses(obj) prm.SetAddresses(obj)
_, err = db.Inhume(prm) _, err = db.Inhume(prm)
require.NoError(t, err) require.NoError(t, err)
@ -189,11 +189,11 @@ func benchmarkGet(b *testing.B, numOfObj int) {
b.ResetTimer() b.ResetTimer()
var getPrm meta.GetPrm var getPrm meta.GetPrm
getPrm.WithAddress(addrs[len(addrs)/2]) getPrm.SetAddress(addrs[len(addrs)/2])
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
for _, addr := range addrs { for _, addr := range addrs {
getPrm.WithAddress(addr) getPrm.SetAddress(addr)
res, err := db.Get(getPrm) res, err := db.Get(getPrm)
require.NoError(b, err) require.NoError(b, err)
@ -206,8 +206,8 @@ func benchmarkGet(b *testing.B, numOfObj int) {
func metaGet(db *meta.DB, addr oid.Address, raw bool) (*objectSDK.Object, error) { func metaGet(db *meta.DB, addr oid.Address, raw bool) (*objectSDK.Object, error) {
var prm meta.GetPrm var prm meta.GetPrm
prm.WithAddress(addr) prm.SetAddress(addr)
prm.WithRaw(raw) prm.SetRaw(raw)
res, err := db.Get(prm) res, err := db.Get(prm)
return res.Header(), err return res.Header(), err

View file

@ -64,8 +64,8 @@ func TestDB_Iterate_OffsetNotFound(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses(object.AddressOf(obj1)) inhumePrm.SetAddresses(object.AddressOf(obj1))
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
@ -134,14 +134,14 @@ func TestDB_IterateDeletedObjects(t *testing.T) {
// inhume with tombstone // inhume with tombstone
addrTombstone := oidtest.Address() addrTombstone := oidtest.Address()
inhumePrm.WithAddresses(object.AddressOf(obj1), object.AddressOf(obj2)) inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
inhumePrm.WithTombstoneAddress(addrTombstone) inhumePrm.SetTombstoneAddress(addrTombstone)
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
inhumePrm.WithAddresses(object.AddressOf(obj3), object.AddressOf(obj4)) inhumePrm.SetAddresses(object.AddressOf(obj3), object.AddressOf(obj4))
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
// inhume with GC mark // inhume with GC mark
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
@ -219,10 +219,10 @@ func TestDB_IterateOverGraveyard_Offset(t *testing.T) {
addrTombstone := oidtest.Address() addrTombstone := oidtest.Address()
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses( inhumePrm.SetAddresses(
object.AddressOf(obj1), object.AddressOf(obj2), object.AddressOf(obj1), object.AddressOf(obj2),
object.AddressOf(obj3), object.AddressOf(obj4)) object.AddressOf(obj3), object.AddressOf(obj4))
inhumePrm.WithTombstoneAddress(addrTombstone) inhumePrm.SetTombstoneAddress(addrTombstone)
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
@ -314,10 +314,10 @@ func TestDB_IterateOverGarbage_Offset(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses( inhumePrm.SetAddresses(
object.AddressOf(obj1), object.AddressOf(obj2), object.AddressOf(obj1), object.AddressOf(obj2),
object.AddressOf(obj3), object.AddressOf(obj4)) object.AddressOf(obj3), object.AddressOf(obj4))
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
@ -400,8 +400,8 @@ func TestDB_DropGraves(t *testing.T) {
addrTombstone := oidtest.Address() addrTombstone := oidtest.Address()
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses(object.AddressOf(obj1), object.AddressOf(obj2)) inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
inhumePrm.WithTombstoneAddress(addrTombstone) inhumePrm.SetTombstoneAddress(addrTombstone)
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)

View file

@ -34,48 +34,37 @@ func (i InhumeRes) DeletedLockObjects() []oid.Address {
return i.deletedLockObj return i.deletedLockObj
} }
// WithAddresses sets a list of object addresses that should be inhumed. // SetAddresses sets a list of object addresses that should be inhumed.
func (p *InhumePrm) WithAddresses(addrs ...oid.Address) { func (p *InhumePrm) SetAddresses(addrs ...oid.Address) {
if p != nil { p.target = addrs
p.target = addrs
}
} }
// WithTombstoneAddress sets tombstone address as the reason for inhume operation. // SetTombstoneAddress sets tombstone address as the reason for inhume operation.
// //
// addr should not be nil. // addr should not be nil.
// Should not be called along with WithGCMark. // Should not be called along with SetGCMark.
func (p *InhumePrm) WithTombstoneAddress(addr oid.Address) { func (p *InhumePrm) SetTombstoneAddress(addr oid.Address) {
if p != nil { p.tomb = &addr
p.tomb = &addr
}
} }
// WithGCMark marks the object to be physically removed. // SetGCMark marks the object to be physically removed.
// //
// Should not be called along with WithTombstoneAddress. // Should not be called along with SetTombstoneAddress.
func (p *InhumePrm) WithGCMark() { func (p *InhumePrm) SetGCMark() {
if p != nil { p.tomb = nil
p.tomb = nil
p.forceRemoval = false
}
} }
// WithLockObjectHandling checks if there were // SetLockObjectHandling checks if there were
// any LOCK object among the targets set via WithAddresses. // any LOCK object among the targets set via WithAddresses.
func (p *InhumePrm) WithLockObjectHandling() { func (p *InhumePrm) SetLockObjectHandling() {
if p != nil { p.lockObjectHandling = true
p.lockObjectHandling = true
}
} }
// WithForceGCMark allows removal any object. Expected to be // SetForceGCMark allows removal any object. Expected to be
// called only in control service. // called only in control service.
func (p *InhumePrm) WithForceGCMark() { func (p *InhumePrm) SetForceGCMark() {
if p != nil { p.tomb = nil
p.tomb = nil p.forceRemoval = true
p.forceRemoval = true
}
} }
var errBreakBucketForEach = errors.New("bucket ForEach break") var errBreakBucketForEach = errors.New("bucket ForEach break")

View file

@ -45,21 +45,21 @@ func TestInhumeTombOnTomb(t *testing.T) {
existsPrm meta.ExistsPrm existsPrm meta.ExistsPrm
) )
inhumePrm.WithAddresses(addr1) inhumePrm.SetAddresses(addr1)
inhumePrm.WithTombstoneAddress(addr2) inhumePrm.SetTombstoneAddress(addr2)
// inhume addr1 via addr2 // inhume addr1 via addr2
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
existsPrm.WithAddress(addr1) existsPrm.SetAddress(addr1)
// addr1 should become inhumed {addr1:addr2} // addr1 should become inhumed {addr1:addr2}
_, err = db.Exists(existsPrm) _, err = db.Exists(existsPrm)
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved)) require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
inhumePrm.WithAddresses(addr3) inhumePrm.SetAddresses(addr3)
inhumePrm.WithTombstoneAddress(addr1) inhumePrm.SetTombstoneAddress(addr1)
// try to inhume addr3 via addr1 // try to inhume addr3 via addr1
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
@ -72,20 +72,20 @@ func TestInhumeTombOnTomb(t *testing.T) {
_, err = db.Exists(existsPrm) _, err = db.Exists(existsPrm)
require.ErrorAs(t, err, new(apistatus.ObjectNotFound)) require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
existsPrm.WithAddress(addr3) existsPrm.SetAddress(addr3)
// addr3 should be inhumed {addr3: addr1} // addr3 should be inhumed {addr3: addr1}
_, err = db.Exists(existsPrm) _, err = db.Exists(existsPrm)
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved)) require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
inhumePrm.WithAddresses(addr1) inhumePrm.SetAddresses(addr1)
inhumePrm.WithTombstoneAddress(oidtest.Address()) inhumePrm.SetTombstoneAddress(oidtest.Address())
// try to inhume addr1 (which is already a tombstone in graveyard) // try to inhume addr1 (which is already a tombstone in graveyard)
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
existsPrm.WithAddress(addr1) existsPrm.SetAddress(addr1)
// record with addr1 key should not appear in graveyard // record with addr1 key should not appear in graveyard
// (tomb can not be inhumed) but should be kept as object // (tomb can not be inhumed) but should be kept as object
@ -103,7 +103,7 @@ func TestInhumeLocked(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
var prm meta.InhumePrm var prm meta.InhumePrm
prm.WithAddresses(locked) prm.SetAddresses(locked)
_, err = db.Inhume(prm) _, err = db.Inhume(prm)
@ -113,8 +113,8 @@ func TestInhumeLocked(t *testing.T) {
func metaInhume(db *meta.DB, target, tomb oid.Address) error { func metaInhume(db *meta.DB, target, tomb oid.Address) error {
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses(target) inhumePrm.SetAddresses(target)
inhumePrm.WithTombstoneAddress(tomb) inhumePrm.SetTombstoneAddress(tomb)
_, err := db.Inhume(inhumePrm) _, err := db.Inhume(inhumePrm)
return err return err

View file

@ -77,14 +77,14 @@ func TestDB_IterateCoveredByTombstones(t *testing.T) {
var prm meta.InhumePrm var prm meta.InhumePrm
var err error var err error
prm.WithAddresses(protected1, protected2, protectedLocked) prm.SetAddresses(protected1, protected2, protectedLocked)
prm.WithTombstoneAddress(ts) prm.SetTombstoneAddress(ts)
_, err = db.Inhume(prm) _, err = db.Inhume(prm)
require.NoError(t, err) require.NoError(t, err)
prm.WithAddresses(garbage) prm.SetAddresses(garbage)
prm.WithGCMark() prm.SetGCMark()
_, err = db.Inhume(prm) _, err = db.Inhume(prm)
require.NoError(t, err) require.NoError(t, err)

View file

@ -26,15 +26,15 @@ type ListPrm struct {
cursor *Cursor cursor *Cursor
} }
// WithCount sets maximum amount of addresses that ListWithCursor should return. // SetCount sets maximum amount of addresses that ListWithCursor should return.
func (l *ListPrm) WithCount(count uint32) { func (l *ListPrm) SetCount(count uint32) {
l.count = int(count) l.count = int(count)
} }
// WithCursor sets cursor for ListWithCursor operation. For initial request // SetCursor sets cursor for ListWithCursor operation. For initial request
// ignore this param or use nil value. For consecutive requests, use value // ignore this param or use nil value. For consecutive requests, use value
// from ListRes. // from ListRes.
func (l *ListPrm) WithCursor(cursor *Cursor) { func (l *ListPrm) SetCursor(cursor *Cursor) {
l.cursor = cursor l.cursor = cursor
} }

View file

@ -46,7 +46,7 @@ func listWithCursorPrepareDB(b *testing.B) *meta.DB {
func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) { func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
var prm meta.ListPrm var prm meta.ListPrm
prm.WithCount(uint32(batchSize)) prm.SetCount(uint32(batchSize))
b.ResetTimer() b.ResetTimer()
b.ReportAllocs() b.ReportAllocs()
@ -56,11 +56,11 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
if err != meta.ErrEndOfListing { if err != meta.ErrEndOfListing {
b.Fatalf("error: %v", err) b.Fatalf("error: %v", err)
} }
prm.WithCursor(nil) prm.SetCursor(nil)
} else if ln := len(res.AddressList()); ln != batchSize { } else if ln := len(res.AddressList()); ln != batchSize {
b.Fatalf("invalid batch size: %d", ln) b.Fatalf("invalid batch size: %d", ln)
} else { } else {
prm.WithCursor(res.Cursor()) prm.SetCursor(res.Cursor())
} }
} }
} }
@ -225,8 +225,8 @@ func sortAddresses(addr []oid.Address) []oid.Address {
func metaListWithCursor(db *meta.DB, count uint32, cursor *meta.Cursor) ([]oid.Address, *meta.Cursor, error) { func metaListWithCursor(db *meta.DB, count uint32, cursor *meta.Cursor) ([]oid.Address, *meta.Cursor, error) {
var listPrm meta.ListPrm var listPrm meta.ListPrm
listPrm.WithCount(count) listPrm.SetCount(count)
listPrm.WithCursor(cursor) listPrm.SetCursor(cursor)
r, err := db.ListWithCursor(listPrm) r, err := db.ListWithCursor(listPrm)
return r.AddressList(), r.Cursor(), err return r.AddressList(), r.Cursor(), err

View file

@ -59,31 +59,31 @@ func TestDB_Lock(t *testing.T) {
lockAddr := objectcore.AddressOf(lockObj) lockAddr := objectcore.AddressOf(lockObj)
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
// check locking relation // check locking relation
inhumePrm.WithAddresses(objAddr) inhumePrm.SetAddresses(objAddr)
_, err := db.Inhume(inhumePrm) _, err := db.Inhume(inhumePrm)
require.ErrorAs(t, err, new(apistatus.ObjectLocked)) require.ErrorAs(t, err, new(apistatus.ObjectLocked))
inhumePrm.WithTombstoneAddress(oidtest.Address()) inhumePrm.SetTombstoneAddress(oidtest.Address())
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.ErrorAs(t, err, new(apistatus.ObjectLocked)) require.ErrorAs(t, err, new(apistatus.ObjectLocked))
// try to remove lock object // try to remove lock object
inhumePrm.WithAddresses(lockAddr) inhumePrm.SetAddresses(lockAddr)
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.Error(t, err) require.Error(t, err)
// check that locking relation has not been // check that locking relation has not been
// dropped // dropped
inhumePrm.WithAddresses(objAddr) inhumePrm.SetAddresses(objAddr)
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.ErrorAs(t, err, new(apistatus.ObjectLocked)) require.ErrorAs(t, err, new(apistatus.ObjectLocked))
inhumePrm.WithTombstoneAddress(oidtest.Address()) inhumePrm.SetTombstoneAddress(oidtest.Address())
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
require.ErrorAs(t, err, new(apistatus.ObjectLocked)) require.ErrorAs(t, err, new(apistatus.ObjectLocked))
}) })
@ -100,9 +100,9 @@ func TestDB_Lock(t *testing.T) {
// free locked object // free locked object
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses(lockAddr) inhumePrm.SetAddresses(lockAddr)
inhumePrm.WithForceGCMark() inhumePrm.SetForceGCMark()
inhumePrm.WithLockObjectHandling() inhumePrm.SetLockObjectHandling()
res, err := db.Inhume(inhumePrm) res, err := db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
@ -112,8 +112,8 @@ func TestDB_Lock(t *testing.T) {
err = db.FreeLockedBy([]oid.Address{lockAddr}) err = db.FreeLockedBy([]oid.Address{lockAddr})
require.NoError(t, err) require.NoError(t, err)
inhumePrm.WithAddresses(objAddr) inhumePrm.SetAddresses(objAddr)
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
// now we can inhume the object // now we can inhume the object
_, err = db.Inhume(inhumePrm) _, err = db.Inhume(inhumePrm)
@ -129,9 +129,9 @@ func TestDB_Lock(t *testing.T) {
// force remove objects // force remove objects
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithForceGCMark() inhumePrm.SetForceGCMark()
inhumePrm.WithAddresses(objectcore.AddressOf(lockObj)) inhumePrm.SetAddresses(objectcore.AddressOf(lockObj))
inhumePrm.WithLockObjectHandling() inhumePrm.SetLockObjectHandling()
res, err := db.Inhume(inhumePrm) res, err := db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
@ -145,10 +145,10 @@ func TestDB_Lock(t *testing.T) {
// removing objects after unlock // removing objects after unlock
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
for i := 0; i < objsNum; i++ { for i := 0; i < objsNum; i++ {
inhumePrm.WithAddresses(objectcore.AddressOf(objs[i])) inhumePrm.SetAddresses(objectcore.AddressOf(objs[i]))
res, err = db.Inhume(inhumePrm) res, err = db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)
@ -160,8 +160,8 @@ func TestDB_Lock(t *testing.T) {
_, lockObj := putAndLockObj(t, db, 1) _, lockObj := putAndLockObj(t, db, 1)
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithForceGCMark() inhumePrm.SetForceGCMark()
inhumePrm.WithAddresses(objectcore.AddressOf(lockObj)) inhumePrm.SetAddresses(objectcore.AddressOf(lockObj))
res, err := db.Inhume(inhumePrm) res, err := db.Inhume(inhumePrm)
require.NoError(t, err) require.NoError(t, err)

View file

@ -15,11 +15,9 @@ type ToMoveItPrm struct {
// ToMoveItRes groups the resulting values of ToMoveIt operation. // ToMoveItRes groups the resulting values of ToMoveIt operation.
type ToMoveItRes struct{} type ToMoveItRes struct{}
// WithAddress sets address of the object to move into another shard. // SetAddress sets address of the object to move into another shard.
func (p *ToMoveItPrm) WithAddress(addr oid.Address) { func (p *ToMoveItPrm) SetAddress(addr oid.Address) {
if p != nil { p.addr = addr
p.addr = addr
}
} }
// DoNotMovePrm groups the parameters of DoNotMove operation. // DoNotMovePrm groups the parameters of DoNotMove operation.
@ -30,11 +28,9 @@ type DoNotMovePrm struct {
// DoNotMoveRes groups the resulting values of DoNotMove operation. // DoNotMoveRes groups the resulting values of DoNotMove operation.
type DoNotMoveRes struct{} type DoNotMoveRes struct{}
// WithAddress sets address of the object to prevent moving into another shard. // SetAddress sets address of the object to prevent moving into another shard.
func (p *DoNotMovePrm) WithAddress(addr oid.Address) { func (p *DoNotMovePrm) SetAddress(addr oid.Address) {
if p != nil { p.addr = addr
p.addr = addr
}
} }
// MovablePrm groups the parameters of Movable operation. // MovablePrm groups the parameters of Movable operation.

View file

@ -58,7 +58,7 @@ func TestDB_Movable(t *testing.T) {
func metaToMoveIt(db *meta.DB, addr oid.Address) error { func metaToMoveIt(db *meta.DB, addr oid.Address) error {
var toMovePrm meta.ToMoveItPrm var toMovePrm meta.ToMoveItPrm
toMovePrm.WithAddress(addr) toMovePrm.SetAddress(addr)
_, err := db.ToMoveIt(toMovePrm) _, err := db.ToMoveIt(toMovePrm)
return err return err
@ -75,7 +75,7 @@ func metaMovable(db *meta.DB) ([]oid.Address, error) {
func metaDoNotMove(db *meta.DB, addr oid.Address) error { func metaDoNotMove(db *meta.DB, addr oid.Address) error {
var doNotMovePrm meta.DoNotMovePrm var doNotMovePrm meta.DoNotMovePrm
doNotMovePrm.WithAddress(addr) doNotMovePrm.SetAddress(addr)
_, err := db.DoNotMove(doNotMovePrm) _, err := db.DoNotMove(doNotMovePrm)
return err return err

View file

@ -33,18 +33,14 @@ type PutPrm struct {
// PutRes groups the resulting values of Put operation. // PutRes groups the resulting values of Put operation.
type PutRes struct{} type PutRes struct{}
// WithObject is a Put option to set object to save. // SetObject is a Put option to set object to save.
func (p *PutPrm) WithObject(obj *objectSDK.Object) { func (p *PutPrm) SetObject(obj *objectSDK.Object) {
if p != nil { p.obj = obj
p.obj = obj
}
} }
// WithBlobovniczaID is a Put option to set blobovnicza ID to save. // SetBlobovniczaID is a Put option to set blobovnicza ID to save.
func (p *PutPrm) WithBlobovniczaID(id *blobovnicza.ID) { func (p *PutPrm) SetBlobovniczaID(id *blobovnicza.ID) {
if p != nil { p.id = id
p.id = id
}
} }
var ( var (

View file

@ -114,8 +114,8 @@ func TestDB_PutBlobovnicaUpdate(t *testing.T) {
func metaPut(db *meta.DB, obj *objectSDK.Object, id *blobovnicza.ID) error { func metaPut(db *meta.DB, obj *objectSDK.Object, id *blobovnicza.ID) error {
var putPrm meta.PutPrm var putPrm meta.PutPrm
putPrm.WithObject(obj) putPrm.SetObject(obj)
putPrm.WithBlobovniczaID(id) putPrm.SetBlobovniczaID(id)
_, err := db.Put(putPrm) _, err := db.Put(putPrm)

View file

@ -39,18 +39,14 @@ type SelectRes struct {
addrList []oid.Address addrList []oid.Address
} }
// WithContainerID is a Select option to set the container id to search in. // SetContainerID is a Select option to set the container id to search in.
func (p *SelectPrm) WithContainerID(cnr cid.ID) { func (p *SelectPrm) SetContainerID(cnr cid.ID) {
if p != nil { p.cnr = cnr
p.cnr = cnr
}
} }
// WithFilters is a Select option to set the object filters. // SetFilters is a Select option to set the object filters.
func (p *SelectPrm) WithFilters(fs object.SearchFilters) { func (p *SelectPrm) SetFilters(fs object.SearchFilters) {
if p != nil { p.filters = fs
p.filters = fs
}
} }
// AddressList returns list of addresses of the selected objects. // AddressList returns list of addresses of the selected objects.

View file

@ -807,8 +807,8 @@ func BenchmarkSelect(b *testing.B) {
func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.SearchFilters, expected int) { func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.SearchFilters, expected int) {
var prm meta.SelectPrm var prm meta.SelectPrm
prm.WithContainerID(cid) prm.SetContainerID(cid)
prm.WithFilters(fs) prm.SetFilters(fs)
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
res, err := db.Select(prm) res, err := db.Select(prm)
@ -823,8 +823,8 @@ func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.Sear
func metaSelect(db *meta.DB, cnr cidSDK.ID, fs objectSDK.SearchFilters) ([]oid.Address, error) { func metaSelect(db *meta.DB, cnr cidSDK.ID, fs objectSDK.SearchFilters) ([]oid.Address, error) {
var prm meta.SelectPrm var prm meta.SelectPrm
prm.WithFilters(fs) prm.SetFilters(fs)
prm.WithContainerID(cnr) prm.SetContainerID(cnr)
res, err := db.Select(prm) res, err := db.Select(prm)
return res.AddressList(), err return res.AddressList(), err

View file

@ -121,8 +121,8 @@ func (s *Shard) refillMetabase() error {
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithTombstoneAddress(tombAddr) inhumePrm.SetTombstoneAddress(tombAddr)
inhumePrm.WithAddresses(tombMembers...) inhumePrm.SetAddresses(tombMembers...)
_, err = s.metaBase.Inhume(inhumePrm) _, err = s.metaBase.Inhume(inhumePrm)
if err != nil { if err != nil {
@ -146,8 +146,8 @@ func (s *Shard) refillMetabase() error {
} }
var mPrm meta.PutPrm var mPrm meta.PutPrm
mPrm.WithObject(obj) mPrm.SetObject(obj)
mPrm.WithBlobovniczaID(blzID) mPrm.SetBlobovniczaID(blzID)
_, err := s.metaBase.Put(mPrm) _, err := s.metaBase.Put(mPrm)
if err != nil && !meta.IsErrRemoved(err) { if err != nil && !meta.IsErrRemoved(err) {

View file

@ -65,7 +65,7 @@ func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error) {
} }
var delPrm meta.DeletePrm var delPrm meta.DeletePrm
delPrm.WithAddresses(prm.addr...) delPrm.SetAddresses(prm.addr...)
_, err := s.metaBase.Delete(delPrm) _, err := s.metaBase.Delete(delPrm)
if err != nil { if err != nil {

View file

@ -39,7 +39,7 @@ func (p ExistsRes) Exists() bool {
// Returns an error of type apistatus.ObjectAlreadyRemoved if object has been marked as removed. // Returns an error of type apistatus.ObjectAlreadyRemoved if object has been marked as removed.
func (s *Shard) Exists(prm ExistsPrm) (ExistsRes, error) { func (s *Shard) Exists(prm ExistsPrm) (ExistsRes, error) {
var existsPrm meta.ExistsPrm var existsPrm meta.ExistsPrm
existsPrm.WithAddress(prm.addr) existsPrm.SetAddress(prm.addr)
res, err := s.metaBase.Exists(existsPrm) res, err := s.metaBase.Exists(existsPrm)
exists := res.Exists() exists := res.Exists()

View file

@ -236,8 +236,8 @@ func (s *Shard) collectExpiredObjects(ctx context.Context, e Event) {
var inhumePrm meta.InhumePrm var inhumePrm meta.InhumePrm
inhumePrm.WithAddresses(expired...) inhumePrm.SetAddresses(expired...)
inhumePrm.WithGCMark() inhumePrm.SetGCMark()
// inhume the collected objects // inhume the collected objects
_, err = s.metaBase.Inhume(inhumePrm) _, err = s.metaBase.Inhume(inhumePrm)
@ -349,8 +349,8 @@ func (s *Shard) HandleExpiredTombstones(tss []meta.TombstonedObject) {
tsAddrs = append(tsAddrs, ts.Tombstone()) tsAddrs = append(tsAddrs, ts.Tombstone())
} }
pInhume.WithGCMark() pInhume.SetGCMark()
pInhume.WithAddresses(tsAddrs...) pInhume.SetAddresses(tsAddrs...)
// inhume tombstones // inhume tombstones
_, err := s.metaBase.Inhume(pInhume) _, err := s.metaBase.Inhume(pInhume)
@ -383,8 +383,8 @@ func (s *Shard) HandleExpiredLocks(lockers []oid.Address) {
} }
var pInhume meta.InhumePrm var pInhume meta.InhumePrm
pInhume.WithAddresses(lockers...) pInhume.SetAddresses(lockers...)
pInhume.WithGCMark() pInhume.SetGCMark()
_, err = s.metaBase.Inhume(pInhume) _, err = s.metaBase.Inhume(pInhume)
if err != nil { if err != nil {

View file

@ -120,7 +120,7 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, big, small stor
var exists bool var exists bool
if !skipMeta { if !skipMeta {
var mPrm meta.ExistsPrm var mPrm meta.ExistsPrm
mPrm.WithAddress(addr) mPrm.SetAddress(addr)
mRes, err := s.metaBase.Exists(mPrm) mRes, err := s.metaBase.Exists(mPrm)
if err != nil && s.GetMode() != ModeDegraded { if err != nil && s.GetMode() != ModeDegraded {

View file

@ -68,8 +68,8 @@ func (s *Shard) Head(prm HeadPrm) (HeadRes, error) {
} }
var headParams meta.GetPrm var headParams meta.GetPrm
headParams.WithAddress(prm.addr) headParams.SetAddress(prm.addr)
headParams.WithRaw(prm.raw) headParams.SetRaw(prm.raw)
res, err := s.metaBase.Get(headParams) res, err := s.metaBase.Get(headParams)
if err != nil { if err != nil {

View file

@ -74,17 +74,17 @@ func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) {
} }
var metaPrm meta.InhumePrm var metaPrm meta.InhumePrm
metaPrm.WithAddresses(prm.target...) metaPrm.SetAddresses(prm.target...)
metaPrm.WithLockObjectHandling() metaPrm.SetLockObjectHandling()
if prm.tombstone != nil { if prm.tombstone != nil {
metaPrm.WithTombstoneAddress(*prm.tombstone) metaPrm.SetTombstoneAddress(*prm.tombstone)
} else { } else {
metaPrm.WithGCMark() metaPrm.SetGCMark()
} }
if prm.forceRemoval { if prm.forceRemoval {
metaPrm.WithForceGCMark() metaPrm.SetForceGCMark()
} }
res, err := s.metaBase.Inhume(metaPrm) res, err := s.metaBase.Inhume(metaPrm)

View file

@ -74,8 +74,8 @@ func (s *Shard) List() (res SelectRes, err error) {
for i := range lst { for i := range lst {
var sPrm meta.SelectPrm var sPrm meta.SelectPrm
sPrm.WithContainerID(lst[i]) sPrm.SetContainerID(lst[i])
sPrm.WithFilters(filters) sPrm.SetFilters(filters)
sRes, err := s.metaBase.Select(sPrm) // consider making List in metabase sRes, err := s.metaBase.Select(sPrm) // consider making List in metabase
if err != nil { if err != nil {
@ -120,8 +120,8 @@ func ListContainers(s *Shard) ([]cid.ID, error) {
// parameter set to zero. // parameter set to zero.
func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error) { func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error) {
var metaPrm meta.ListPrm var metaPrm meta.ListPrm
metaPrm.WithCount(prm.count) metaPrm.SetCount(prm.count)
metaPrm.WithCursor(prm.cursor) metaPrm.SetCursor(prm.cursor)
res, err := s.metaBase.ListWithCursor(metaPrm) res, err := s.metaBase.ListWithCursor(metaPrm)
if err != nil { if err != nil {
return ListWithCursorRes{}, fmt.Errorf("could not get list of objects: %w", err) return ListWithCursorRes{}, fmt.Errorf("could not get list of objects: %w", err)

View file

@ -30,7 +30,7 @@ func (s *Shard) ToMoveIt(prm ToMoveItPrm) (ToMoveItRes, error) {
} }
var toMovePrm meta.ToMoveItPrm var toMovePrm meta.ToMoveItPrm
toMovePrm.WithAddress(prm.addr) toMovePrm.SetAddress(prm.addr)
_, err := s.metaBase.ToMoveIt(toMovePrm) _, err := s.metaBase.ToMoveIt(toMovePrm)
if err != nil { if err != nil {

View file

@ -61,8 +61,8 @@ func (s *Shard) Put(prm PutPrm) (PutRes, error) {
// put to metabase // put to metabase
var pPrm meta.PutPrm var pPrm meta.PutPrm
pPrm.WithObject(prm.obj) pPrm.SetObject(prm.obj)
pPrm.WithBlobovniczaID(res.BlobovniczaID()) pPrm.SetBlobovniczaID(res.BlobovniczaID())
if _, err := s.metaBase.Put(pPrm); err != nil { if _, err := s.metaBase.Put(pPrm); err != nil {
// may we need to handle this case in a special way // may we need to handle this case in a special way
// since the object has been successfully written to BlobStor // since the object has been successfully written to BlobStor

View file

@ -45,8 +45,8 @@ func (r SelectRes) AddressList() []oid.Address {
// did not allow to completely select the objects. // did not allow to completely select the objects.
func (s *Shard) Select(prm SelectPrm) (SelectRes, error) { func (s *Shard) Select(prm SelectPrm) (SelectRes, error) {
var selectPrm meta.SelectPrm var selectPrm meta.SelectPrm
selectPrm.WithFilters(prm.filters) selectPrm.SetFilters(prm.filters)
selectPrm.WithContainerID(prm.cnr) selectPrm.SetContainerID(prm.cnr)
mRes, err := s.metaBase.Select(selectPrm) mRes, err := s.metaBase.Select(selectPrm)
if err != nil { if err != nil {

View file

@ -239,8 +239,8 @@ func (c *cache) writeObject(obj *object.Object, metaOnly bool) error {
} }
var pPrm meta.PutPrm var pPrm meta.PutPrm
pPrm.WithObject(obj) pPrm.SetObject(obj)
pPrm.WithBlobovniczaID(id) pPrm.SetBlobovniczaID(id)
_, err := c.metabase.Put(pPrm) _, err := c.metabase.Put(pPrm)
return err return err

View file

@ -60,7 +60,7 @@ func (c *cache) initFlushMarks() {
func (c *cache) isFlushed(addr oid.Address) bool { func (c *cache) isFlushed(addr oid.Address) bool {
var existsPrm meta.ExistsPrm var existsPrm meta.ExistsPrm
existsPrm.WithAddress(addr) existsPrm.SetAddress(addr)
mRes, err := c.metabase.Exists(existsPrm) mRes, err := c.metabase.Exists(existsPrm)
if err != nil || !mRes.Exists() { if err != nil || !mRes.Exists() {