2020-10-21 11:49:02 +00:00
|
|
|
package replicator
|
|
|
|
|
|
|
|
import (
|
2021-11-10 07:08:33 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
2022-09-19 10:57:59 +00:00
|
|
|
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
2022-05-31 17:00:41 +00:00
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
2020-10-21 11:49:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Task represents group of Replicator task parameters.
|
|
|
|
type Task struct {
|
|
|
|
quantity uint32
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
addr oid.Address
|
2020-10-21 11:49:02 +00:00
|
|
|
|
2022-09-19 10:57:59 +00:00
|
|
|
obj *objectSDK.Object
|
|
|
|
|
2022-06-08 23:18:26 +00:00
|
|
|
nodes []netmap.NodeInfo
|
2020-10-21 11:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WithCopiesNumber sets number of copies to replicate.
|
|
|
|
func (t *Task) WithCopiesNumber(v uint32) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.quantity = v
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithObjectAddress sets address of local object.
|
2022-05-31 17:00:41 +00:00
|
|
|
func (t *Task) WithObjectAddress(v oid.Address) *Task {
|
2020-10-21 11:49:02 +00:00
|
|
|
if t != nil {
|
|
|
|
t.addr = v
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2022-09-19 10:57:59 +00:00
|
|
|
// WithObject sets object to avoid fetching it from the local storage.
|
|
|
|
func (t *Task) WithObject(obj *objectSDK.Object) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.obj = obj
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// WithNodes sets a list of potential object holders.
|
2022-06-08 23:18:26 +00:00
|
|
|
func (t *Task) WithNodes(v []netmap.NodeInfo) *Task {
|
2020-10-21 11:49:02 +00:00
|
|
|
if t != nil {
|
|
|
|
t.nodes = v
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|