[#1786] engine: Unify parameter setters

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-09-14 17:36:37 +03:00 committed by fyrchik
parent b064fb24d8
commit 5321f8ef9c
7 changed files with 16 additions and 42 deletions

View file

@ -23,18 +23,14 @@ type DeleteRes struct{}
//
// Option is required.
func (p *DeletePrm) WithAddress(addr oid.Address) {
if p != nil {
p.addr = addr
}
}
// WithForceRemoval is a Delete option to remove an object despite any
// restrictions imposed on deleting that object. Expected to be used
// only in control service.
func (p *DeletePrm) WithForceRemoval() {
if p != nil {
p.forceRemoval = true
}
}
// Delete marks the objects to be removed.

View file

@ -25,9 +25,7 @@ type GetRes struct {
//
// Option is required.
func (p *GetPrm) WithAddress(addr oid.Address) {
if p != nil {
p.addr = addr
}
}
// Object returns the requested object.

View file

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

View file

@ -28,29 +28,23 @@ type InhumeRes struct{}
// 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 {
p.addrs = addrs
p.tombstone = &tombstone
}
}
// MarkAsGarbage marks an object to be physically removed from local storage.
//
// Should not be called along with WithTarget.
func (p *InhumePrm) MarkAsGarbage(addrs ...oid.Address) {
if p != nil {
p.addrs = addrs
p.tombstone = nil
}
}
// WithForceRemoval inhumes objects specified via MarkAsGarbage with GC mark
// without any object restrictions checks.
func (p *InhumePrm) WithForceRemoval() {
if p != nil {
p.forceRemoval = true
p.tombstone = nil
}
}
var errInhumeFailure = errors.New("inhume operation failed")

View file

@ -23,9 +23,7 @@ var errPutShard = errors.New("could not put object to any shard")
//
// Option is required.
func (p *PutPrm) WithObject(obj *objectSDK.Object) {
if p != nil {
p.obj = obj
}
}
// Put saves the object to local storage.

View file

@ -27,9 +27,7 @@ type RngRes struct {
//
// Option is required.
func (p *RngPrm) WithAddress(addr oid.Address) {
if p != nil {
p.addr = addr
}
}
// WithPayloadRange is a GetRange option to set range of requested payload data.
@ -37,9 +35,7 @@ func (p *RngPrm) WithAddress(addr oid.Address) {
// Missing an option or calling with zero length is equivalent
// to getting the full payload range.
func (p *RngPrm) WithPayloadRange(rng *objectSDK.Range) {
if p != nil {
p.off, p.ln = rng.GetOffset(), rng.GetLength()
}
}
// Object returns the requested object part.

View file

@ -20,16 +20,12 @@ type SelectRes struct {
// 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
}
}
// WithFilters is a Select option to set the object filters.
func (p *SelectPrm) WithFilters(fs object.SearchFilters) {
if p != nil {
p.filters = fs
}
}
// AddressList returns list of addresses of the selected objects.