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

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-07-13 15:43:04 +03:00 committed by fyrchik
parent 7b882b26d8
commit d8ba954aff
34 changed files with 114 additions and 142 deletions

View file

@ -72,7 +72,7 @@ func (e *StorageEngine) containerSize(prm ContainerSizePrm) (res ContainerSizeRe
e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) {
var csPrm shard.ContainerSizePrm
csPrm.WithContainerID(prm.cnr)
csPrm.SetContainerID(prm.cnr)
csRes, err := sh.Shard.ContainerSize(csPrm)
if err != nil {

View file

@ -68,7 +68,7 @@ func (e *StorageEngine) delete(prm DeletePrm) (DeleteRes, error) {
for i := range prm.addr {
e.iterateOverSortedShards(prm.addr[i], func(_ int, sh hashedShard) (stop bool) {
var existsPrm shard.ExistsPrm
existsPrm.WithAddress(prm.addr[i])
existsPrm.SetAddress(prm.addr[i])
resExists, err := sh.Exists(existsPrm)
if err != nil {

View file

@ -70,7 +70,7 @@ func TestErrorReporting(t *testing.T) {
obj.SetPayload(make([]byte, errSmallSize))
var prm shard.PutPrm
prm.WithObject(obj)
prm.SetObject(obj)
e.mtx.RLock()
_, err := e.shards[id[0].String()].Shard.Put(prm)
e.mtx.RUnlock()
@ -100,7 +100,7 @@ func TestErrorReporting(t *testing.T) {
obj.SetPayload(make([]byte, errSmallSize))
var prm shard.PutPrm
prm.WithObject(obj)
prm.SetObject(obj)
e.mtx.RLock()
_, err := e.shards[id[0].String()].Put(prm)
e.mtx.RUnlock()
@ -150,7 +150,7 @@ func TestBlobstorFailback(t *testing.T) {
obj.SetPayload(make([]byte, size))
var prm shard.PutPrm
prm.WithObject(obj)
prm.SetObject(obj)
e.mtx.RLock()
_, err = e.shards[id[0].String()].Shard.Put(prm)
e.mtx.RUnlock()

View file

@ -8,7 +8,7 @@ import (
func (e *StorageEngine) exists(addr oid.Address) (bool, error) {
var shPrm shard.ExistsPrm
shPrm.WithAddress(addr)
shPrm.SetAddress(addr)
alreadyRemoved := false
exists := false

View file

@ -72,7 +72,7 @@ func (e *StorageEngine) get(prm GetPrm) (GetRes, error) {
)
var shPrm shard.GetPrm
shPrm.WithAddress(prm.addr)
shPrm.SetAddress(prm.addr)
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Get(shPrm)
@ -129,7 +129,7 @@ func (e *StorageEngine) get(prm GetPrm) (GetRes, error) {
// If the object is not found but is present in metabase,
// try to fetch it from blobstor directly. If it is found in any
// blobstor, increase the error counter for the shard which contains the meta.
shPrm.WithIgnoreMeta(true)
shPrm.SetIgnoreMeta(true)
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Get(shPrm)

View file

@ -80,8 +80,8 @@ func (e *StorageEngine) head(prm HeadPrm) (HeadRes, error) {
)
var shPrm shard.HeadPrm
shPrm.WithAddress(prm.addr)
shPrm.WithRaw(prm.raw)
shPrm.SetAddress(prm.addr)
shPrm.SetRaw(prm.raw)
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Head(shPrm)

View file

@ -47,10 +47,10 @@ func TestHeadRaw(t *testing.T) {
defer e.Close()
var putPrmLeft shard.PutPrm
putPrmLeft.WithObject(child)
putPrmLeft.SetObject(child)
var putPrmLink shard.PutPrm
putPrmLink.WithObject(link)
putPrmLink.SetObject(link)
// put most left object in one shard
_, err := s1.Put(putPrmLeft)

View file

@ -86,7 +86,7 @@ func (e *StorageEngine) inhume(prm InhumePrm) (InhumeRes, error) {
for i := range prm.addrs {
if prm.tombstone != nil {
shPrm.WithTarget(*prm.tombstone, prm.addrs[i])
shPrm.SetTarget(*prm.tombstone, prm.addrs[i])
} else {
shPrm.MarkAsGarbage(prm.addrs[i])
}
@ -129,7 +129,7 @@ func (e *StorageEngine) inhumeAddr(addr oid.Address, prm shard.InhumePrm, checkE
}()
if checkExists {
existPrm.WithAddress(addr)
existPrm.SetAddress(addr)
exRes, err := sh.Exists(existPrm)
if err != nil {
if shard.IsErrRemoved(err) {

View file

@ -62,12 +62,12 @@ func TestStorageEngine_Inhume(t *testing.T) {
defer e.Close()
var putChild shard.PutPrm
putChild.WithObject(child)
putChild.SetObject(child)
_, err := s1.Put(putChild)
require.NoError(t, err)
var putLink shard.PutPrm
putLink.WithObject(link)
putLink.SetObject(link)
_, err = s2.Put(putLink)
require.NoError(t, err)

View file

@ -66,7 +66,7 @@ func (e *StorageEngine) lockSingle(idCnr cid.ID, locker, locked oid.ID, checkExi
if checkExists {
var existsPrm shard.ExistsPrm
existsPrm.WithAddress(addrLocked)
existsPrm.SetAddress(addrLocked)
exRes, err := sh.Exists(existsPrm)
if err != nil {

View file

@ -60,7 +60,7 @@ func (e *StorageEngine) put(prm PutPrm) (PutRes, error) {
}
var existPrm shard.ExistsPrm
existPrm.WithAddress(addr)
existPrm.SetAddress(addr)
finished := false
@ -82,7 +82,7 @@ func (e *StorageEngine) put(prm PutPrm) (PutRes, error) {
if exists.Exists() {
if ind != 0 {
var toMoveItPrm shard.ToMoveItPrm
toMoveItPrm.WithAddress(addr)
toMoveItPrm.SetAddress(addr)
_, err = sh.ToMoveIt(toMoveItPrm)
if err != nil {
@ -99,7 +99,7 @@ func (e *StorageEngine) put(prm PutPrm) (PutRes, error) {
}
var putPrm shard.PutPrm
putPrm.WithObject(prm.obj)
putPrm.SetObject(prm.obj)
_, err = sh.Put(putPrm)
if err != nil {

View file

@ -87,8 +87,8 @@ func (e *StorageEngine) getRange(prm RngPrm) (RngRes, error) {
)
var shPrm shard.RngPrm
shPrm.WithAddress(prm.addr)
shPrm.WithRange(prm.off, prm.ln)
shPrm.SetAddress(prm.addr)
shPrm.SetRange(prm.off, prm.ln)
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.GetRange(shPrm)
@ -147,7 +147,7 @@ func (e *StorageEngine) getRange(prm RngPrm) (RngRes, error) {
// If the object is not found but is present in metabase,
// try to fetch it from blobstor directly. If it is found in any
// blobstor, increase the error counter for the shard which contains the meta.
shPrm.WithIgnoreMeta(true)
shPrm.SetIgnoreMeta(true)
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.GetRange(shPrm)

View file

@ -62,8 +62,8 @@ func (e *StorageEngine) _select(prm SelectPrm) (SelectRes, error) {
var outError error
var shPrm shard.SelectPrm
shPrm.WithContainerID(prm.cnr)
shPrm.WithFilters(prm.filters)
shPrm.SetContainerID(prm.cnr)
shPrm.SetFilters(prm.filters)
e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) {
res, err := sh.Select(shPrm)

View file

@ -14,10 +14,8 @@ type ContainerSizeRes struct {
size uint64
}
func (p *ContainerSizePrm) WithContainerID(cnr cid.ID) {
if p != nil {
func (p *ContainerSizePrm) SetContainerID(cnr cid.ID) {
p.cnr = cnr
}
}
func (r ContainerSizeRes) Size() uint64 {

View file

@ -42,7 +42,7 @@ func TestRefillMetabaseCorrupted(t *testing.T) {
obj.SetPayload([]byte{0, 1, 2, 3, 4, 5})
var putPrm PutPrm
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
require.NoError(t, sh.Close())
@ -64,7 +64,7 @@ func TestRefillMetabaseCorrupted(t *testing.T) {
require.NoError(t, sh.Init())
var getPrm GetPrm
getPrm.WithAddress(addr)
getPrm.SetAddress(addr)
_, err = sh.Get(getPrm)
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
require.NoError(t, sh.Close())
@ -150,13 +150,13 @@ func TestRefillMetabase(t *testing.T) {
var putPrm PutPrm
for _, v := range mObjs {
putPrm.WithObject(v.obj)
putPrm.SetObject(v.obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
}
putPrm.WithObject(tombObj)
putPrm.SetObject(tombObj)
_, err = sh.Put(putPrm)
require.NoError(t, err)
@ -169,7 +169,7 @@ func TestRefillMetabase(t *testing.T) {
lockObj.SetContainerID(cnrLocked)
objectSDK.WriteLock(lockObj, lock)
putPrm.WithObject(lockObj)
putPrm.SetObject(lockObj)
_, err = sh.Put(putPrm)
require.NoError(t, err)
@ -177,7 +177,7 @@ func TestRefillMetabase(t *testing.T) {
require.NoError(t, sh.Lock(cnrLocked, lockID, locked))
var inhumePrm InhumePrm
inhumePrm.WithTarget(object.AddressOf(tombObj), tombMembers...)
inhumePrm.SetTarget(object.AddressOf(tombObj), tombMembers...)
_, err = sh.Inhume(inhumePrm)
require.NoError(t, err)
@ -185,7 +185,7 @@ func TestRefillMetabase(t *testing.T) {
var headPrm HeadPrm
checkObj := func(addr oid.Address, expObj *objectSDK.Object) {
headPrm.WithAddress(addr)
headPrm.SetAddress(addr)
res, err := sh.Head(headPrm)
@ -210,7 +210,7 @@ func TestRefillMetabase(t *testing.T) {
checkTombMembers := func(exists bool) {
for _, member := range tombMembers {
headPrm.WithAddress(member)
headPrm.SetAddress(member)
_, err := sh.Head(headPrm)

View file

@ -17,13 +17,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(addr ...oid.Address) {
if p != nil {
func (p *DeletePrm) SetAddresses(addr ...oid.Address) {
p.addr = append(p.addr, addr...)
}
}
// Delete removes data from the shard's writeCache, metaBase and

View file

@ -36,11 +36,11 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
t.Run("big object", func(t *testing.T) {
addPayload(obj, 1<<20)
putPrm.WithObject(obj)
getPrm.WithAddress(object.AddressOf(obj))
putPrm.SetObject(obj)
getPrm.SetAddress(object.AddressOf(obj))
var delPrm shard.DeletePrm
delPrm.WithAddresses(object.AddressOf(obj))
delPrm.SetAddresses(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)
@ -59,11 +59,11 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
obj.SetID(oidtest.ID())
addPayload(obj, 1<<5)
putPrm.WithObject(obj)
getPrm.WithAddress(object.AddressOf(obj))
putPrm.SetObject(obj)
getPrm.SetAddress(object.AddressOf(obj))
var delPrm shard.DeletePrm
delPrm.WithAddresses(object.AddressOf(obj))
delPrm.SetAddresses(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)

View file

@ -95,7 +95,7 @@ func testDump(t *testing.T, objCount int, hasWriteCache bool) {
objects[i] = obj
var prm shard.PutPrm
prm.WithObject(objects[i])
prm.SetObject(objects[i])
_, err := sh.Put(prm)
require.NoError(t, err)
}
@ -225,7 +225,7 @@ func TestStream(t *testing.T) {
objects[i] = obj
var prm shard.PutPrm
prm.WithObject(objects[i])
prm.SetObject(objects[i])
_, err := sh1.Put(prm)
require.NoError(t, err)
}
@ -268,7 +268,7 @@ func checkRestore(t *testing.T, sh *shard.Shard, prm shard.RestorePrm, objects [
var getPrm shard.GetPrm
for i := range objects {
getPrm.WithAddress(object.AddressOf(objects[i]))
getPrm.SetAddress(object.AddressOf(objects[i]))
res, err := sh.Get(getPrm)
require.NoError(t, err)
require.Equal(t, objects[i], res.Object())
@ -311,7 +311,7 @@ func TestDumpIgnoreErrors(t *testing.T) {
objects[i] = obj
var prm shard.PutPrm
prm.WithObject(objects[i])
prm.SetObject(objects[i])
_, err := sh.Put(prm)
require.NoError(t, err)
}

View file

@ -17,13 +17,9 @@ type ExistsRes struct {
ex bool
}
// WithAddress is an Exists option to set object checked for existence.
func (p *ExistsPrm) WithAddress(addr oid.Address) *ExistsPrm {
if p != nil {
// SetAddress is an Exists option to set object checked for existence.
func (p *ExistsPrm) SetAddress(addr oid.Address) {
p.addr = addr
}
return p
}
// Exists returns the fact that the object is in the shard.

View file

@ -210,7 +210,7 @@ func (s *Shard) removeGarbage() {
}
var deletePrm DeletePrm
deletePrm.WithAddresses(buf...)
deletePrm.SetAddresses(buf...)
// delete accumulated objects
_, err = s.Delete(deletePrm)

View file

@ -29,18 +29,16 @@ type GetRes struct {
hasMeta bool
}
// 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 {
func (p *GetPrm) SetAddress(addr oid.Address) {
p.addr = addr
}
}
// WithIgnoreMeta is a Get option try to fetch object from blobstor directly,
// SetIgnoreMeta is a Get option try to fetch object from blobstor directly,
// without accessing metabase.
func (p *GetPrm) WithIgnoreMeta(ignore bool) {
func (p *GetPrm) SetIgnoreMeta(ignore bool) {
p.skipMeta = ignore
}

View file

@ -36,12 +36,12 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
addAttribute(obj, "foo", "bar")
addPayload(obj, 1<<5)
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
getPrm.WithAddress(object.AddressOf(obj))
getPrm.SetAddress(object.AddressOf(obj))
res, err := testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
@ -54,12 +54,12 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
obj.SetID(oidtest.ID())
addPayload(obj, 1<<20) // big obj
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
getPrm.WithAddress(object.AddressOf(obj))
getPrm.SetAddress(object.AddressOf(obj))
res, err := testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
@ -82,18 +82,18 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
child.SetSplitID(splitID)
addPayload(child, 1<<5)
putPrm.WithObject(child)
putPrm.SetObject(child)
_, err := sh.Put(putPrm)
require.NoError(t, err)
getPrm.WithAddress(object.AddressOf(child))
getPrm.SetAddress(object.AddressOf(child))
res, err := testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
require.True(t, binaryEqual(child, res.Object()))
getPrm.WithAddress(object.AddressOf(parent))
getPrm.SetAddress(object.AddressOf(parent))
_, err = testGet(t, sh, getPrm, hasWriteCache)

View file

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

View file

@ -33,12 +33,12 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
obj := generateObject(t)
addAttribute(obj, "foo", "bar")
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
headPrm.WithAddress(object.AddressOf(obj))
headPrm.SetAddress(object.AddressOf(obj))
res, err := testHead(t, sh, headPrm, hasWriteCache)
require.NoError(t, err)
@ -58,21 +58,21 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
child.SetParentID(idParent)
child.SetSplitID(splitID)
putPrm.WithObject(child)
putPrm.SetObject(child)
_, err := sh.Put(putPrm)
require.NoError(t, err)
headPrm.WithAddress(object.AddressOf(parent))
headPrm.WithRaw(true)
headPrm.SetAddress(object.AddressOf(parent))
headPrm.SetRaw(true)
var siErr *objectSDK.SplitInfoError
_, err = testHead(t, sh, headPrm, hasWriteCache)
require.True(t, errors.As(err, &siErr))
headPrm.WithAddress(object.AddressOf(parent))
headPrm.WithRaw(false)
headPrm.SetAddress(object.AddressOf(parent))
headPrm.SetRaw(false)
head, err := sh.Head(headPrm)
require.NoError(t, err)

View file

@ -20,21 +20,19 @@ type InhumePrm struct {
// InhumeRes encapsulates results of inhume operation.
type InhumeRes struct{}
// WithTarget sets a list of objects that should be inhumed and tombstone address
// SetTarget sets a list of objects that should be inhumed and tombstone address
// as the reason for inhume operation.
//
// tombstone should not be nil, addr should not be empty.
// Should not be called along with MarkAsGarbage.
func (p *InhumePrm) WithTarget(tombstone oid.Address, addrs ...oid.Address) {
if p != nil {
func (p *InhumePrm) SetTarget(tombstone oid.Address, addrs ...oid.Address) {
p.target = addrs
p.tombstone = &tombstone
}
}
// MarkAsGarbage marks object to be physically removed from shard.
//
// Should not be called along with WithTarget.
// Should not be called along with SetTarget.
func (p *InhumePrm) MarkAsGarbage(addr ...oid.Address) {
if p != nil {
p.target = addr

View file

@ -32,13 +32,13 @@ func testShardInhume(t *testing.T, hasWriteCache bool) {
ts := generateObjectWithCID(t, cnr)
var putPrm shard.PutPrm
putPrm.WithObject(obj)
putPrm.SetObject(obj)
var inhPrm shard.InhumePrm
inhPrm.WithTarget(object.AddressOf(ts), object.AddressOf(obj))
inhPrm.SetTarget(object.AddressOf(ts), object.AddressOf(obj))
var getPrm shard.GetPrm
getPrm.WithAddress(object.AddressOf(obj))
getPrm.SetAddress(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)

View file

@ -49,7 +49,7 @@ func testShardList(t *testing.T, sh *shard.Shard) {
objs[object.AddressOf(obj).EncodeToString()] = 0
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)

View file

@ -57,7 +57,7 @@ func TestShard_Lock(t *testing.T) {
// put the object
var putPrm shard.PutPrm
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
@ -67,7 +67,7 @@ func TestShard_Lock(t *testing.T) {
err = sh.Lock(cnr, lockID, []oid.ID{objID})
require.NoError(t, err)
putPrm.WithObject(lock)
putPrm.SetObject(lock)
_, err = sh.Put(putPrm)
require.NoError(t, err)
@ -75,7 +75,7 @@ func TestShard_Lock(t *testing.T) {
ts := generateObjectWithCID(t, cnr)
var inhumePrm shard.InhumePrm
inhumePrm.WithTarget(objectcore.AddressOf(ts), objectcore.AddressOf(obj))
inhumePrm.SetTarget(objectcore.AddressOf(ts), objectcore.AddressOf(obj))
_, err = sh.Inhume(inhumePrm)
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
@ -89,7 +89,7 @@ func TestShard_Lock(t *testing.T) {
ts := generateObjectWithCID(t, cnr)
var inhumePrm shard.InhumePrm
inhumePrm.WithTarget(objectcore.AddressOf(ts), objectcore.AddressOf(lock))
inhumePrm.SetTarget(objectcore.AddressOf(ts), objectcore.AddressOf(lock))
_, err = sh.Inhume(inhumePrm)
require.Error(t, err)
@ -119,7 +119,7 @@ func TestShard_Lock(t *testing.T) {
// check that object has been removed
var getPrm shard.GetPrm
getPrm.WithAddress(objectcore.AddressOf(obj))
getPrm.SetAddress(objectcore.AddressOf(obj))
_, err = sh.Get(getPrm)
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))

View file

@ -14,12 +14,10 @@ type ToMoveItPrm struct {
// ToMoveItRes encapsulates results of ToMoveIt operation.
type ToMoveItRes struct{}
// WithAddress sets object address that should be marked to move into another
// SetAddress sets object address that should be marked to move into another
// shard.
func (p *ToMoveItPrm) WithAddress(addr oid.Address) {
if p != nil {
func (p *ToMoveItPrm) SetAddress(addr oid.Address) {
p.addr = addr
}
}
// ToMoveIt calls metabase.ToMoveIt method to mark object as relocatable to

View file

@ -17,11 +17,9 @@ 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 *object.Object) {
if p != nil {
// SetObject is a Put option to set object to save.
func (p *PutPrm) SetObject(obj *object.Object) {
p.obj = obj
}
}
// Put saves the object in shard.

View file

@ -24,25 +24,21 @@ type RngRes struct {
hasMeta bool
}
// WithAddress is a Rng option to set the address of the requested object.
// SetAddress is a Rng option to set the address of the requested object.
//
// Option is required.
func (p *RngPrm) WithAddress(addr oid.Address) {
if p != nil {
func (p *RngPrm) SetAddress(addr oid.Address) {
p.addr = addr
}
}
// WithRange is a GetRange option to set range of requested payload data.
func (p *RngPrm) WithRange(off uint64, ln uint64) {
if p != nil {
// SetRange is a GetRange option to set range of requested payload data.
func (p *RngPrm) SetRange(off uint64, ln uint64) {
p.off, p.ln = off, ln
}
}
// WithIgnoreMeta is a Get option try to fetch object from blobstor directly,
// SetIgnoreMeta is a Get option try to fetch object from blobstor directly,
// without accessing metabase.
func (p *RngPrm) WithIgnoreMeta(ignore bool) {
func (p *RngPrm) SetIgnoreMeta(ignore bool) {
p.skipMeta = ignore
}

View file

@ -120,7 +120,7 @@ func (s *Shard) Restore(prm RestorePrm) (RestoreRes, error) {
return RestoreRes{}, err
}
putPrm.WithObject(obj)
putPrm.SetObject(obj)
_, err = s.Put(putPrm)
if err != nil {
return RestoreRes{}, err

View file

@ -20,18 +20,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 {
// 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 {
// 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.

View file

@ -40,7 +40,7 @@ func TestWriteCacheObjectLoss(t *testing.T) {
var putPrm shard.PutPrm
for i := range objects {
putPrm.WithObject(objects[i])
putPrm.SetObject(objects[i])
_, err := sh.Put(putPrm)
require.NoError(t, err)
}
@ -52,7 +52,7 @@ func TestWriteCacheObjectLoss(t *testing.T) {
var getPrm shard.GetPrm
for i := range objects {
getPrm.WithAddress(object.AddressOf(objects[i]))
getPrm.SetAddress(object.AddressOf(objects[i]))
_, err := sh.Get(getPrm)
require.NoError(t, err, i)