diff --git a/pkg/local_object_storage/metabase/control_test.go b/pkg/local_object_storage/metabase/control_test.go index 765b39b66a..df549031a4 100644 --- a/pkg/local_object_storage/metabase/control_test.go +++ b/pkg/local_object_storage/metabase/control_test.go @@ -52,7 +52,7 @@ func TestReset(t *testing.T) { func metaExists(db *meta.DB, addr oid.Address) (bool, error) { var existsPrm meta.ExistsPrm - existsPrm.WithAddress(addr) + existsPrm.SetAddress(addr) res, err := db.Exists(existsPrm) return res.Exists(), err diff --git a/pkg/local_object_storage/metabase/delete.go b/pkg/local_object_storage/metabase/delete.go index b72e5cfe3c..d161670758 100644 --- a/pkg/local_object_storage/metabase/delete.go +++ b/pkg/local_object_storage/metabase/delete.go @@ -21,13 +21,11 @@ type DeletePrm struct { // DeleteRes groups the resulting values of Delete operation. 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. -func (p *DeletePrm) WithAddresses(addrs ...oid.Address) { - if p != nil { - p.addrs = addrs - } +func (p *DeletePrm) SetAddresses(addrs ...oid.Address) { + p.addrs = addrs } type referenceNumber struct { diff --git a/pkg/local_object_storage/metabase/delete_test.go b/pkg/local_object_storage/metabase/delete_test.go index 748f1f921b..bdb4860b35 100644 --- a/pkg/local_object_storage/metabase/delete_test.go +++ b/pkg/local_object_storage/metabase/delete_test.go @@ -120,7 +120,7 @@ func TestGraveOnlyDelete(t *testing.T) { func metaDelete(db *meta.DB, addrs ...oid.Address) error { var deletePrm meta.DeletePrm - deletePrm.WithAddresses(addrs...) + deletePrm.SetAddresses(addrs...) _, err := db.Delete(deletePrm) return err diff --git a/pkg/local_object_storage/metabase/exists.go b/pkg/local_object_storage/metabase/exists.go index 5ec468db73..cb0602e5c3 100644 --- a/pkg/local_object_storage/metabase/exists.go +++ b/pkg/local_object_storage/metabase/exists.go @@ -23,11 +23,9 @@ type ExistsRes struct { var ErrLackSplitInfo = errors.New("no split info on parent object") -// WithAddress is an Exists option to set object checked for existence. -func (p *ExistsPrm) WithAddress(addr oid.Address) { - if p != nil { - p.addr = addr - } +// SetAddress is an Exists option to set object checked for existence. +func (p *ExistsPrm) SetAddress(addr oid.Address) { + p.addr = addr } // Exists returns the fact that the object is in the metabase. diff --git a/pkg/local_object_storage/metabase/get.go b/pkg/local_object_storage/metabase/get.go index 611aeff67e..5812c373d2 100644 --- a/pkg/local_object_storage/metabase/get.go +++ b/pkg/local_object_storage/metabase/get.go @@ -21,22 +21,18 @@ type GetRes struct { 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. -func (p *GetPrm) WithAddress(addr oid.Address) { - if p != nil { - p.addr = addr - } +func (p *GetPrm) SetAddress(addr oid.Address) { + 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 // object. -func (p *GetPrm) WithRaw(raw bool) { - if p != nil { - p.raw = raw - } +func (p *GetPrm) SetRaw(raw bool) { + p.raw = raw } // Header returns the requested object header. diff --git a/pkg/local_object_storage/metabase/get_test.go b/pkg/local_object_storage/metabase/get_test.go index 0a17793fee..633354cfbf 100644 --- a/pkg/local_object_storage/metabase/get_test.go +++ b/pkg/local_object_storage/metabase/get_test.go @@ -128,7 +128,7 @@ func TestDB_Get(t *testing.T) { obj = oidtest.Address() var prm meta.InhumePrm - prm.WithAddresses(obj) + prm.SetAddresses(obj) _, err = db.Inhume(prm) require.NoError(t, err) @@ -189,11 +189,11 @@ func benchmarkGet(b *testing.B, numOfObj int) { b.ResetTimer() var getPrm meta.GetPrm - getPrm.WithAddress(addrs[len(addrs)/2]) + getPrm.SetAddress(addrs[len(addrs)/2]) for i := 0; i < b.N; i++ { for _, addr := range addrs { - getPrm.WithAddress(addr) + getPrm.SetAddress(addr) res, err := db.Get(getPrm) 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) { var prm meta.GetPrm - prm.WithAddress(addr) - prm.WithRaw(raw) + prm.SetAddress(addr) + prm.SetRaw(raw) res, err := db.Get(prm) return res.Header(), err diff --git a/pkg/local_object_storage/metabase/graveyard_test.go b/pkg/local_object_storage/metabase/graveyard_test.go index 63e0065775..c0f54c7e2f 100644 --- a/pkg/local_object_storage/metabase/graveyard_test.go +++ b/pkg/local_object_storage/metabase/graveyard_test.go @@ -64,8 +64,8 @@ func TestDB_Iterate_OffsetNotFound(t *testing.T) { require.NoError(t, err) var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses(object.AddressOf(obj1)) - inhumePrm.WithGCMark() + inhumePrm.SetAddresses(object.AddressOf(obj1)) + inhumePrm.SetGCMark() _, err = db.Inhume(inhumePrm) require.NoError(t, err) @@ -134,14 +134,14 @@ func TestDB_IterateDeletedObjects(t *testing.T) { // inhume with tombstone addrTombstone := oidtest.Address() - inhumePrm.WithAddresses(object.AddressOf(obj1), object.AddressOf(obj2)) - inhumePrm.WithTombstoneAddress(addrTombstone) + inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2)) + inhumePrm.SetTombstoneAddress(addrTombstone) _, err = db.Inhume(inhumePrm) require.NoError(t, err) - inhumePrm.WithAddresses(object.AddressOf(obj3), object.AddressOf(obj4)) - inhumePrm.WithGCMark() + inhumePrm.SetAddresses(object.AddressOf(obj3), object.AddressOf(obj4)) + inhumePrm.SetGCMark() // inhume with GC mark _, err = db.Inhume(inhumePrm) @@ -219,10 +219,10 @@ func TestDB_IterateOverGraveyard_Offset(t *testing.T) { addrTombstone := oidtest.Address() var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses( + inhumePrm.SetAddresses( object.AddressOf(obj1), object.AddressOf(obj2), object.AddressOf(obj3), object.AddressOf(obj4)) - inhumePrm.WithTombstoneAddress(addrTombstone) + inhumePrm.SetTombstoneAddress(addrTombstone) _, err = db.Inhume(inhumePrm) require.NoError(t, err) @@ -314,10 +314,10 @@ func TestDB_IterateOverGarbage_Offset(t *testing.T) { require.NoError(t, err) var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses( + inhumePrm.SetAddresses( object.AddressOf(obj1), object.AddressOf(obj2), object.AddressOf(obj3), object.AddressOf(obj4)) - inhumePrm.WithGCMark() + inhumePrm.SetGCMark() _, err = db.Inhume(inhumePrm) require.NoError(t, err) @@ -400,8 +400,8 @@ func TestDB_DropGraves(t *testing.T) { addrTombstone := oidtest.Address() var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses(object.AddressOf(obj1), object.AddressOf(obj2)) - inhumePrm.WithTombstoneAddress(addrTombstone) + inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2)) + inhumePrm.SetTombstoneAddress(addrTombstone) _, err = db.Inhume(inhumePrm) require.NoError(t, err) diff --git a/pkg/local_object_storage/metabase/inhume.go b/pkg/local_object_storage/metabase/inhume.go index bd85047fe5..1643a5759e 100644 --- a/pkg/local_object_storage/metabase/inhume.go +++ b/pkg/local_object_storage/metabase/inhume.go @@ -34,48 +34,37 @@ func (i InhumeRes) DeletedLockObjects() []oid.Address { return i.deletedLockObj } -// WithAddresses sets a list of object addresses that should be inhumed. -func (p *InhumePrm) WithAddresses(addrs ...oid.Address) { - if p != nil { - p.target = addrs - } +// SetAddresses sets a list of object addresses that should be inhumed. +func (p *InhumePrm) SetAddresses(addrs ...oid.Address) { + 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. -// Should not be called along with WithGCMark. -func (p *InhumePrm) WithTombstoneAddress(addr oid.Address) { - if p != nil { - p.tomb = &addr - } +// Should not be called along with SetGCMark. +func (p *InhumePrm) SetTombstoneAddress(addr oid.Address) { + 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. -func (p *InhumePrm) WithGCMark() { - if p != nil { - p.tomb = nil - p.forceRemoval = false - } +// Should not be called along with SetTombstoneAddress. +func (p *InhumePrm) SetGCMark() { + p.tomb = nil } -// WithLockObjectHandling checks if there were +// SetLockObjectHandling checks if there were // any LOCK object among the targets set via WithAddresses. -func (p *InhumePrm) WithLockObjectHandling() { - if p != nil { - p.lockObjectHandling = true - } +func (p *InhumePrm) SetLockObjectHandling() { + p.lockObjectHandling = true } -// WithForceGCMark allows removal any object. Expected to be +// SetForceGCMark allows removal any object. Expected to be // called only in control service. -func (p *InhumePrm) WithForceGCMark() { - if p != nil { - p.tomb = nil - p.forceRemoval = true - } +func (p *InhumePrm) SetForceGCMark() { + p.tomb = nil + p.forceRemoval = true } var errBreakBucketForEach = errors.New("bucket ForEach break") diff --git a/pkg/local_object_storage/metabase/inhume_test.go b/pkg/local_object_storage/metabase/inhume_test.go index 92f53dbdbe..6e47b10706 100644 --- a/pkg/local_object_storage/metabase/inhume_test.go +++ b/pkg/local_object_storage/metabase/inhume_test.go @@ -45,21 +45,21 @@ func TestInhumeTombOnTomb(t *testing.T) { existsPrm meta.ExistsPrm ) - inhumePrm.WithAddresses(addr1) - inhumePrm.WithTombstoneAddress(addr2) + inhumePrm.SetAddresses(addr1) + inhumePrm.SetTombstoneAddress(addr2) // inhume addr1 via addr2 _, err = db.Inhume(inhumePrm) require.NoError(t, err) - existsPrm.WithAddress(addr1) + existsPrm.SetAddress(addr1) // addr1 should become inhumed {addr1:addr2} _, err = db.Exists(existsPrm) require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved)) - inhumePrm.WithAddresses(addr3) - inhumePrm.WithTombstoneAddress(addr1) + inhumePrm.SetAddresses(addr3) + inhumePrm.SetTombstoneAddress(addr1) // try to inhume addr3 via addr1 _, err = db.Inhume(inhumePrm) @@ -72,20 +72,20 @@ func TestInhumeTombOnTomb(t *testing.T) { _, err = db.Exists(existsPrm) require.ErrorAs(t, err, new(apistatus.ObjectNotFound)) - existsPrm.WithAddress(addr3) + existsPrm.SetAddress(addr3) // addr3 should be inhumed {addr3: addr1} _, err = db.Exists(existsPrm) require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved)) - inhumePrm.WithAddresses(addr1) - inhumePrm.WithTombstoneAddress(oidtest.Address()) + inhumePrm.SetAddresses(addr1) + inhumePrm.SetTombstoneAddress(oidtest.Address()) // try to inhume addr1 (which is already a tombstone in graveyard) _, err = db.Inhume(inhumePrm) require.NoError(t, err) - existsPrm.WithAddress(addr1) + existsPrm.SetAddress(addr1) // record with addr1 key should not appear in graveyard // (tomb can not be inhumed) but should be kept as object @@ -103,7 +103,7 @@ func TestInhumeLocked(t *testing.T) { require.NoError(t, err) var prm meta.InhumePrm - prm.WithAddresses(locked) + prm.SetAddresses(locked) _, err = db.Inhume(prm) @@ -113,8 +113,8 @@ func TestInhumeLocked(t *testing.T) { func metaInhume(db *meta.DB, target, tomb oid.Address) error { var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses(target) - inhumePrm.WithTombstoneAddress(tomb) + inhumePrm.SetAddresses(target) + inhumePrm.SetTombstoneAddress(tomb) _, err := db.Inhume(inhumePrm) return err diff --git a/pkg/local_object_storage/metabase/iterators_test.go b/pkg/local_object_storage/metabase/iterators_test.go index 52fb173619..2cd0398ce4 100644 --- a/pkg/local_object_storage/metabase/iterators_test.go +++ b/pkg/local_object_storage/metabase/iterators_test.go @@ -77,14 +77,14 @@ func TestDB_IterateCoveredByTombstones(t *testing.T) { var prm meta.InhumePrm var err error - prm.WithAddresses(protected1, protected2, protectedLocked) - prm.WithTombstoneAddress(ts) + prm.SetAddresses(protected1, protected2, protectedLocked) + prm.SetTombstoneAddress(ts) _, err = db.Inhume(prm) require.NoError(t, err) - prm.WithAddresses(garbage) - prm.WithGCMark() + prm.SetAddresses(garbage) + prm.SetGCMark() _, err = db.Inhume(prm) require.NoError(t, err) diff --git a/pkg/local_object_storage/metabase/list.go b/pkg/local_object_storage/metabase/list.go index 12f34a1bc8..2f4b7f295e 100644 --- a/pkg/local_object_storage/metabase/list.go +++ b/pkg/local_object_storage/metabase/list.go @@ -26,15 +26,15 @@ type ListPrm struct { cursor *Cursor } -// WithCount sets maximum amount of addresses that ListWithCursor should return. -func (l *ListPrm) WithCount(count uint32) { +// SetCount sets maximum amount of addresses that ListWithCursor should return. +func (l *ListPrm) SetCount(count uint32) { 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 // from ListRes. -func (l *ListPrm) WithCursor(cursor *Cursor) { +func (l *ListPrm) SetCursor(cursor *Cursor) { l.cursor = cursor } diff --git a/pkg/local_object_storage/metabase/list_test.go b/pkg/local_object_storage/metabase/list_test.go index 899c6c92e0..bef33eb132 100644 --- a/pkg/local_object_storage/metabase/list_test.go +++ b/pkg/local_object_storage/metabase/list_test.go @@ -46,7 +46,7 @@ func listWithCursorPrepareDB(b *testing.B) *meta.DB { func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) { var prm meta.ListPrm - prm.WithCount(uint32(batchSize)) + prm.SetCount(uint32(batchSize)) b.ResetTimer() b.ReportAllocs() @@ -56,11 +56,11 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) { if err != meta.ErrEndOfListing { b.Fatalf("error: %v", err) } - prm.WithCursor(nil) + prm.SetCursor(nil) } else if ln := len(res.AddressList()); ln != batchSize { b.Fatalf("invalid batch size: %d", ln) } 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) { var listPrm meta.ListPrm - listPrm.WithCount(count) - listPrm.WithCursor(cursor) + listPrm.SetCount(count) + listPrm.SetCursor(cursor) r, err := db.ListWithCursor(listPrm) return r.AddressList(), r.Cursor(), err diff --git a/pkg/local_object_storage/metabase/lock_test.go b/pkg/local_object_storage/metabase/lock_test.go index 31d418755a..1bd16754f1 100644 --- a/pkg/local_object_storage/metabase/lock_test.go +++ b/pkg/local_object_storage/metabase/lock_test.go @@ -59,31 +59,31 @@ func TestDB_Lock(t *testing.T) { lockAddr := objectcore.AddressOf(lockObj) var inhumePrm meta.InhumePrm - inhumePrm.WithGCMark() + inhumePrm.SetGCMark() // check locking relation - inhumePrm.WithAddresses(objAddr) + inhumePrm.SetAddresses(objAddr) _, err := db.Inhume(inhumePrm) require.ErrorAs(t, err, new(apistatus.ObjectLocked)) - inhumePrm.WithTombstoneAddress(oidtest.Address()) + inhumePrm.SetTombstoneAddress(oidtest.Address()) _, err = db.Inhume(inhumePrm) require.ErrorAs(t, err, new(apistatus.ObjectLocked)) // try to remove lock object - inhumePrm.WithAddresses(lockAddr) + inhumePrm.SetAddresses(lockAddr) _, err = db.Inhume(inhumePrm) require.Error(t, err) // check that locking relation has not been // dropped - inhumePrm.WithAddresses(objAddr) + inhumePrm.SetAddresses(objAddr) _, err = db.Inhume(inhumePrm) require.ErrorAs(t, err, new(apistatus.ObjectLocked)) - inhumePrm.WithTombstoneAddress(oidtest.Address()) + inhumePrm.SetTombstoneAddress(oidtest.Address()) _, err = db.Inhume(inhumePrm) require.ErrorAs(t, err, new(apistatus.ObjectLocked)) }) @@ -100,9 +100,9 @@ func TestDB_Lock(t *testing.T) { // free locked object var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses(lockAddr) - inhumePrm.WithForceGCMark() - inhumePrm.WithLockObjectHandling() + inhumePrm.SetAddresses(lockAddr) + inhumePrm.SetForceGCMark() + inhumePrm.SetLockObjectHandling() res, err := db.Inhume(inhumePrm) require.NoError(t, err) @@ -112,8 +112,8 @@ func TestDB_Lock(t *testing.T) { err = db.FreeLockedBy([]oid.Address{lockAddr}) require.NoError(t, err) - inhumePrm.WithAddresses(objAddr) - inhumePrm.WithGCMark() + inhumePrm.SetAddresses(objAddr) + inhumePrm.SetGCMark() // now we can inhume the object _, err = db.Inhume(inhumePrm) @@ -129,9 +129,9 @@ func TestDB_Lock(t *testing.T) { // force remove objects var inhumePrm meta.InhumePrm - inhumePrm.WithForceGCMark() - inhumePrm.WithAddresses(objectcore.AddressOf(lockObj)) - inhumePrm.WithLockObjectHandling() + inhumePrm.SetForceGCMark() + inhumePrm.SetAddresses(objectcore.AddressOf(lockObj)) + inhumePrm.SetLockObjectHandling() res, err := db.Inhume(inhumePrm) require.NoError(t, err) @@ -145,10 +145,10 @@ func TestDB_Lock(t *testing.T) { // removing objects after unlock - inhumePrm.WithGCMark() + inhumePrm.SetGCMark() for i := 0; i < objsNum; i++ { - inhumePrm.WithAddresses(objectcore.AddressOf(objs[i])) + inhumePrm.SetAddresses(objectcore.AddressOf(objs[i])) res, err = db.Inhume(inhumePrm) require.NoError(t, err) @@ -160,8 +160,8 @@ func TestDB_Lock(t *testing.T) { _, lockObj := putAndLockObj(t, db, 1) var inhumePrm meta.InhumePrm - inhumePrm.WithForceGCMark() - inhumePrm.WithAddresses(objectcore.AddressOf(lockObj)) + inhumePrm.SetForceGCMark() + inhumePrm.SetAddresses(objectcore.AddressOf(lockObj)) res, err := db.Inhume(inhumePrm) require.NoError(t, err) diff --git a/pkg/local_object_storage/metabase/movable.go b/pkg/local_object_storage/metabase/movable.go index 33ce06f5b2..578c164921 100644 --- a/pkg/local_object_storage/metabase/movable.go +++ b/pkg/local_object_storage/metabase/movable.go @@ -15,11 +15,9 @@ type ToMoveItPrm struct { // ToMoveItRes groups the resulting values of ToMoveIt operation. type ToMoveItRes struct{} -// WithAddress sets address of the object to move into another shard. -func (p *ToMoveItPrm) WithAddress(addr oid.Address) { - if p != nil { - p.addr = addr - } +// SetAddress sets address of the object to move into another shard. +func (p *ToMoveItPrm) SetAddress(addr oid.Address) { + p.addr = addr } // DoNotMovePrm groups the parameters of DoNotMove operation. @@ -30,11 +28,9 @@ type DoNotMovePrm struct { // DoNotMoveRes groups the resulting values of DoNotMove operation. type DoNotMoveRes struct{} -// WithAddress sets address of the object to prevent moving into another shard. -func (p *DoNotMovePrm) WithAddress(addr oid.Address) { - if p != nil { - p.addr = addr - } +// SetAddress sets address of the object to prevent moving into another shard. +func (p *DoNotMovePrm) SetAddress(addr oid.Address) { + p.addr = addr } // MovablePrm groups the parameters of Movable operation. diff --git a/pkg/local_object_storage/metabase/movable_test.go b/pkg/local_object_storage/metabase/movable_test.go index ad1ca08ebd..560b7d4cda 100644 --- a/pkg/local_object_storage/metabase/movable_test.go +++ b/pkg/local_object_storage/metabase/movable_test.go @@ -58,7 +58,7 @@ func TestDB_Movable(t *testing.T) { func metaToMoveIt(db *meta.DB, addr oid.Address) error { var toMovePrm meta.ToMoveItPrm - toMovePrm.WithAddress(addr) + toMovePrm.SetAddress(addr) _, err := db.ToMoveIt(toMovePrm) return err @@ -75,7 +75,7 @@ func metaMovable(db *meta.DB) ([]oid.Address, error) { func metaDoNotMove(db *meta.DB, addr oid.Address) error { var doNotMovePrm meta.DoNotMovePrm - doNotMovePrm.WithAddress(addr) + doNotMovePrm.SetAddress(addr) _, err := db.DoNotMove(doNotMovePrm) return err diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index 0db4330b64..6e36d6656c 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -33,18 +33,14 @@ type PutPrm struct { // PutRes groups the resulting values of Put operation. type PutRes struct{} -// WithObject is a Put option to set object to save. -func (p *PutPrm) WithObject(obj *objectSDK.Object) { - if p != nil { - p.obj = obj - } +// SetObject is a Put option to set object to save. +func (p *PutPrm) SetObject(obj *objectSDK.Object) { + p.obj = obj } -// WithBlobovniczaID is a Put option to set blobovnicza ID to save. -func (p *PutPrm) WithBlobovniczaID(id *blobovnicza.ID) { - if p != nil { - p.id = id - } +// SetBlobovniczaID is a Put option to set blobovnicza ID to save. +func (p *PutPrm) SetBlobovniczaID(id *blobovnicza.ID) { + p.id = id } var ( diff --git a/pkg/local_object_storage/metabase/put_test.go b/pkg/local_object_storage/metabase/put_test.go index bbf8a91c71..82253d0b90 100644 --- a/pkg/local_object_storage/metabase/put_test.go +++ b/pkg/local_object_storage/metabase/put_test.go @@ -114,8 +114,8 @@ func TestDB_PutBlobovnicaUpdate(t *testing.T) { func metaPut(db *meta.DB, obj *objectSDK.Object, id *blobovnicza.ID) error { var putPrm meta.PutPrm - putPrm.WithObject(obj) - putPrm.WithBlobovniczaID(id) + putPrm.SetObject(obj) + putPrm.SetBlobovniczaID(id) _, err := db.Put(putPrm) diff --git a/pkg/local_object_storage/metabase/select.go b/pkg/local_object_storage/metabase/select.go index 7c7e67213f..cb93708368 100644 --- a/pkg/local_object_storage/metabase/select.go +++ b/pkg/local_object_storage/metabase/select.go @@ -39,18 +39,14 @@ type SelectRes struct { addrList []oid.Address } -// WithContainerID is a Select option to set the container id to search in. -func (p *SelectPrm) WithContainerID(cnr cid.ID) { - if p != nil { - p.cnr = cnr - } +// SetContainerID is a Select option to set the container id to search in. +func (p *SelectPrm) SetContainerID(cnr cid.ID) { + p.cnr = cnr } -// WithFilters is a Select option to set the object filters. -func (p *SelectPrm) WithFilters(fs object.SearchFilters) { - if p != nil { - p.filters = fs - } +// SetFilters is a Select option to set the object filters. +func (p *SelectPrm) SetFilters(fs object.SearchFilters) { + p.filters = fs } // AddressList returns list of addresses of the selected objects. diff --git a/pkg/local_object_storage/metabase/select_test.go b/pkg/local_object_storage/metabase/select_test.go index 557ebede56..710758ba59 100644 --- a/pkg/local_object_storage/metabase/select_test.go +++ b/pkg/local_object_storage/metabase/select_test.go @@ -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) { var prm meta.SelectPrm - prm.WithContainerID(cid) - prm.WithFilters(fs) + prm.SetContainerID(cid) + prm.SetFilters(fs) for i := 0; i < b.N; i++ { 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) { var prm meta.SelectPrm - prm.WithFilters(fs) - prm.WithContainerID(cnr) + prm.SetFilters(fs) + prm.SetContainerID(cnr) res, err := db.Select(prm) return res.AddressList(), err diff --git a/pkg/local_object_storage/shard/control.go b/pkg/local_object_storage/shard/control.go index da9abd4705..64713b469a 100644 --- a/pkg/local_object_storage/shard/control.go +++ b/pkg/local_object_storage/shard/control.go @@ -121,8 +121,8 @@ func (s *Shard) refillMetabase() error { var inhumePrm meta.InhumePrm - inhumePrm.WithTombstoneAddress(tombAddr) - inhumePrm.WithAddresses(tombMembers...) + inhumePrm.SetTombstoneAddress(tombAddr) + inhumePrm.SetAddresses(tombMembers...) _, err = s.metaBase.Inhume(inhumePrm) if err != nil { @@ -146,8 +146,8 @@ func (s *Shard) refillMetabase() error { } var mPrm meta.PutPrm - mPrm.WithObject(obj) - mPrm.WithBlobovniczaID(blzID) + mPrm.SetObject(obj) + mPrm.SetBlobovniczaID(blzID) _, err := s.metaBase.Put(mPrm) if err != nil && !meta.IsErrRemoved(err) { diff --git a/pkg/local_object_storage/shard/delete.go b/pkg/local_object_storage/shard/delete.go index 5ec4ea604a..c9458cce77 100644 --- a/pkg/local_object_storage/shard/delete.go +++ b/pkg/local_object_storage/shard/delete.go @@ -65,7 +65,7 @@ func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error) { } var delPrm meta.DeletePrm - delPrm.WithAddresses(prm.addr...) + delPrm.SetAddresses(prm.addr...) _, err := s.metaBase.Delete(delPrm) if err != nil { diff --git a/pkg/local_object_storage/shard/exists.go b/pkg/local_object_storage/shard/exists.go index 149a337e5e..34d93a5147 100644 --- a/pkg/local_object_storage/shard/exists.go +++ b/pkg/local_object_storage/shard/exists.go @@ -39,7 +39,7 @@ func (p ExistsRes) Exists() bool { // Returns an error of type apistatus.ObjectAlreadyRemoved if object has been marked as removed. func (s *Shard) Exists(prm ExistsPrm) (ExistsRes, error) { var existsPrm meta.ExistsPrm - existsPrm.WithAddress(prm.addr) + existsPrm.SetAddress(prm.addr) res, err := s.metaBase.Exists(existsPrm) exists := res.Exists() diff --git a/pkg/local_object_storage/shard/gc.go b/pkg/local_object_storage/shard/gc.go index c119784f15..c34e16e40f 100644 --- a/pkg/local_object_storage/shard/gc.go +++ b/pkg/local_object_storage/shard/gc.go @@ -236,8 +236,8 @@ func (s *Shard) collectExpiredObjects(ctx context.Context, e Event) { var inhumePrm meta.InhumePrm - inhumePrm.WithAddresses(expired...) - inhumePrm.WithGCMark() + inhumePrm.SetAddresses(expired...) + inhumePrm.SetGCMark() // inhume the collected objects _, err = s.metaBase.Inhume(inhumePrm) @@ -349,8 +349,8 @@ func (s *Shard) HandleExpiredTombstones(tss []meta.TombstonedObject) { tsAddrs = append(tsAddrs, ts.Tombstone()) } - pInhume.WithGCMark() - pInhume.WithAddresses(tsAddrs...) + pInhume.SetGCMark() + pInhume.SetAddresses(tsAddrs...) // inhume tombstones _, err := s.metaBase.Inhume(pInhume) @@ -383,8 +383,8 @@ func (s *Shard) HandleExpiredLocks(lockers []oid.Address) { } var pInhume meta.InhumePrm - pInhume.WithAddresses(lockers...) - pInhume.WithGCMark() + pInhume.SetAddresses(lockers...) + pInhume.SetGCMark() _, err = s.metaBase.Inhume(pInhume) if err != nil { diff --git a/pkg/local_object_storage/shard/get.go b/pkg/local_object_storage/shard/get.go index d69518147e..478c4c1011 100644 --- a/pkg/local_object_storage/shard/get.go +++ b/pkg/local_object_storage/shard/get.go @@ -120,7 +120,7 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, big, small stor var exists bool if !skipMeta { var mPrm meta.ExistsPrm - mPrm.WithAddress(addr) + mPrm.SetAddress(addr) mRes, err := s.metaBase.Exists(mPrm) if err != nil && s.GetMode() != ModeDegraded { diff --git a/pkg/local_object_storage/shard/head.go b/pkg/local_object_storage/shard/head.go index 416100f388..62ad70624b 100644 --- a/pkg/local_object_storage/shard/head.go +++ b/pkg/local_object_storage/shard/head.go @@ -68,8 +68,8 @@ func (s *Shard) Head(prm HeadPrm) (HeadRes, error) { } var headParams meta.GetPrm - headParams.WithAddress(prm.addr) - headParams.WithRaw(prm.raw) + headParams.SetAddress(prm.addr) + headParams.SetRaw(prm.raw) res, err := s.metaBase.Get(headParams) if err != nil { diff --git a/pkg/local_object_storage/shard/inhume.go b/pkg/local_object_storage/shard/inhume.go index c154317bb7..4196743828 100644 --- a/pkg/local_object_storage/shard/inhume.go +++ b/pkg/local_object_storage/shard/inhume.go @@ -74,17 +74,17 @@ func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) { } var metaPrm meta.InhumePrm - metaPrm.WithAddresses(prm.target...) - metaPrm.WithLockObjectHandling() + metaPrm.SetAddresses(prm.target...) + metaPrm.SetLockObjectHandling() if prm.tombstone != nil { - metaPrm.WithTombstoneAddress(*prm.tombstone) + metaPrm.SetTombstoneAddress(*prm.tombstone) } else { - metaPrm.WithGCMark() + metaPrm.SetGCMark() } if prm.forceRemoval { - metaPrm.WithForceGCMark() + metaPrm.SetForceGCMark() } res, err := s.metaBase.Inhume(metaPrm) diff --git a/pkg/local_object_storage/shard/list.go b/pkg/local_object_storage/shard/list.go index 6110b6aadd..c899f8635a 100644 --- a/pkg/local_object_storage/shard/list.go +++ b/pkg/local_object_storage/shard/list.go @@ -74,8 +74,8 @@ func (s *Shard) List() (res SelectRes, err error) { for i := range lst { var sPrm meta.SelectPrm - sPrm.WithContainerID(lst[i]) - sPrm.WithFilters(filters) + sPrm.SetContainerID(lst[i]) + sPrm.SetFilters(filters) sRes, err := s.metaBase.Select(sPrm) // consider making List in metabase if err != nil { @@ -120,8 +120,8 @@ func ListContainers(s *Shard) ([]cid.ID, error) { // parameter set to zero. func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error) { var metaPrm meta.ListPrm - metaPrm.WithCount(prm.count) - metaPrm.WithCursor(prm.cursor) + metaPrm.SetCount(prm.count) + metaPrm.SetCursor(prm.cursor) res, err := s.metaBase.ListWithCursor(metaPrm) if err != nil { return ListWithCursorRes{}, fmt.Errorf("could not get list of objects: %w", err) diff --git a/pkg/local_object_storage/shard/move.go b/pkg/local_object_storage/shard/move.go index 3ccb6f97e2..8f1172749b 100644 --- a/pkg/local_object_storage/shard/move.go +++ b/pkg/local_object_storage/shard/move.go @@ -30,7 +30,7 @@ func (s *Shard) ToMoveIt(prm ToMoveItPrm) (ToMoveItRes, error) { } var toMovePrm meta.ToMoveItPrm - toMovePrm.WithAddress(prm.addr) + toMovePrm.SetAddress(prm.addr) _, err := s.metaBase.ToMoveIt(toMovePrm) if err != nil { diff --git a/pkg/local_object_storage/shard/put.go b/pkg/local_object_storage/shard/put.go index ab3ce8a657..7d8696b584 100644 --- a/pkg/local_object_storage/shard/put.go +++ b/pkg/local_object_storage/shard/put.go @@ -61,8 +61,8 @@ func (s *Shard) Put(prm PutPrm) (PutRes, error) { // put to metabase var pPrm meta.PutPrm - pPrm.WithObject(prm.obj) - pPrm.WithBlobovniczaID(res.BlobovniczaID()) + pPrm.SetObject(prm.obj) + pPrm.SetBlobovniczaID(res.BlobovniczaID()) if _, err := s.metaBase.Put(pPrm); err != nil { // may we need to handle this case in a special way // since the object has been successfully written to BlobStor diff --git a/pkg/local_object_storage/shard/select.go b/pkg/local_object_storage/shard/select.go index d7db7b1a8d..aa3d6bdf33 100644 --- a/pkg/local_object_storage/shard/select.go +++ b/pkg/local_object_storage/shard/select.go @@ -45,8 +45,8 @@ func (r SelectRes) AddressList() []oid.Address { // did not allow to completely select the objects. func (s *Shard) Select(prm SelectPrm) (SelectRes, error) { var selectPrm meta.SelectPrm - selectPrm.WithFilters(prm.filters) - selectPrm.WithContainerID(prm.cnr) + selectPrm.SetFilters(prm.filters) + selectPrm.SetContainerID(prm.cnr) mRes, err := s.metaBase.Select(selectPrm) if err != nil { diff --git a/pkg/local_object_storage/writecache/flush.go b/pkg/local_object_storage/writecache/flush.go index 2d3fd897fc..770ff57097 100644 --- a/pkg/local_object_storage/writecache/flush.go +++ b/pkg/local_object_storage/writecache/flush.go @@ -239,8 +239,8 @@ func (c *cache) writeObject(obj *object.Object, metaOnly bool) error { } var pPrm meta.PutPrm - pPrm.WithObject(obj) - pPrm.WithBlobovniczaID(id) + pPrm.SetObject(obj) + pPrm.SetBlobovniczaID(id) _, err := c.metabase.Put(pPrm) return err diff --git a/pkg/local_object_storage/writecache/init.go b/pkg/local_object_storage/writecache/init.go index 452e93153e..d089f5d612 100644 --- a/pkg/local_object_storage/writecache/init.go +++ b/pkg/local_object_storage/writecache/init.go @@ -60,7 +60,7 @@ func (c *cache) initFlushMarks() { func (c *cache) isFlushed(addr oid.Address) bool { var existsPrm meta.ExistsPrm - existsPrm.WithAddress(addr) + existsPrm.SetAddress(addr) mRes, err := c.metabase.Exists(existsPrm) if err != nil || !mRes.Exists() {