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

View file

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

View file

@ -25,19 +25,15 @@ type HeadRes struct {
// //
// Option is required. // Option is required.
func (p *HeadPrm) WithAddress(addr oid.Address) { func (p *HeadPrm) WithAddress(addr oid.Address) {
if p != nil {
p.addr = addr p.addr = addr
} }
}
// WithRaw is a Head option to set raw flag value. If flag is unset, then Head // 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 // returns the header of the virtual object, otherwise it returns SplitInfo of the virtual
// object. // object.
func (p *HeadPrm) WithRaw(raw bool) { func (p *HeadPrm) WithRaw(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

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

View file

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

View file

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

View file

@ -20,17 +20,13 @@ type SelectRes struct {
// WithContainerID is a Select option to set the container id to search in. // WithContainerID is a Select option to set the container id to search in.
func (p *SelectPrm) WithContainerID(cnr cid.ID) { func (p *SelectPrm) WithContainerID(cnr cid.ID) {
if p != nil {
p.cnr = cnr p.cnr = cnr
} }
}
// WithFilters is a Select option to set the object filters. // WithFilters is a Select option to set the object filters.
func (p *SelectPrm) WithFilters(fs object.SearchFilters) { func (p *SelectPrm) WithFilters(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.
func (r SelectRes) AddressList() []oid.Address { func (r SelectRes) AddressList() []oid.Address {