frostfs-node/pkg/services/replicator/task.go
Leonard Lyubich 1c30414a6c [#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes:
 * avoid package-colliding variable naming
 * avoid using pointers to IDs where unnecessary
 * avoid using `idSDK` import alias pattern
 * use `EncodeToString` for protocol string calculation and `String` for
  printing

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-06-01 17:41:45 +03:00

53 lines
944 B
Go

package replicator
import (
"github.com/nspcc-dev/neofs-sdk-go/netmap"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
// Task represents group of Replicator task parameters.
type Task struct {
quantity uint32
addr oid.Address
nodes netmap.Nodes
}
// AddTask pushes replication task to Replicator queue.
//
// If task queue is full, log message is written.
func (p *Replicator) AddTask(t *Task) {
select {
case p.ch <- t:
default:
p.log.Warn("task queue is full")
}
}
// 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.
func (t *Task) WithObjectAddress(v oid.Address) *Task {
if t != nil {
t.addr = v
}
return t
}
// WithNodes sets a list of potential object holders.
func (t *Task) WithNodes(v netmap.Nodes) *Task {
if t != nil {
t.nodes = v
}
return t
}