forked from TrueCloudLab/frostfs-node
[#1786] engine: Unify parameter setters
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
b064fb24d8
commit
5321f8ef9c
7 changed files with 16 additions and 42 deletions
|
@ -23,18 +23,14 @@ 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.
|
||||||
|
|
|
@ -25,9 +25,7 @@ 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.
|
||||||
|
|
|
@ -25,18 +25,14 @@ 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.
|
||||||
|
|
|
@ -28,29 +28,23 @@ 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")
|
||||||
|
|
|
@ -23,9 +23,7 @@ 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.
|
||||||
|
|
|
@ -27,9 +27,7 @@ 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.
|
||||||
|
@ -37,9 +35,7 @@ func (p *RngPrm) WithAddress(addr oid.Address) {
|
||||||
// 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.
|
||||||
|
|
|
@ -20,16 +20,12 @@ 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.
|
||||||
|
|
Loading…
Reference in a new issue