diff --git a/pkg/services/control/server/evacuate.go b/pkg/services/control/server/evacuate.go index d232129aa9..f10bb76438 100644 --- a/pkg/services/control/server/evacuate.go +++ b/pkg/services/control/server/evacuate.go @@ -86,11 +86,11 @@ func (s *Server) replicate(addr oid.Address, obj *objectSDK.Object) error { } var res replicatorResult - task := new(replicator.Task). - WithObject(obj). - WithObjectAddress(addr). - WithCopiesNumber(1). - WithNodes(nodes) + var task replicator.Task + task.SetObject(obj) + task.SetObjectAddress(addr) + task.SetCopiesNumber(1) + task.SetNodes(nodes) s.replicator.HandleTask(context.TODO(), task, &res) if res.count == 0 { diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index 5de6d5cbae..feedc1392d 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -154,11 +154,11 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address, zap.Uint32("shortage", shortage), ) - p.replicator.HandleTask(ctx, new(replicator.Task). - WithObjectAddress(addr). - WithNodes(nodes). - WithCopiesNumber(shortage), - checkedNodes, - ) + var task replicator.Task + task.SetObjectAddress(addr) + task.SetNodes(nodes) + task.SetCopiesNumber(shortage) + + p.replicator.HandleTask(ctx, task, checkedNodes) } } diff --git a/pkg/services/replicator/process.go b/pkg/services/replicator/process.go index 8b4554cc93..90bb8510fa 100644 --- a/pkg/services/replicator/process.go +++ b/pkg/services/replicator/process.go @@ -19,7 +19,7 @@ type TaskResult interface { // HandleTask executes replication task inside invoking goroutine. // Passes all the nodes that accepted the replication to the TaskResult. -func (p *Replicator) HandleTask(ctx context.Context, task *Task, res TaskResult) { +func (p *Replicator) HandleTask(ctx context.Context, task Task, res TaskResult) { defer func() { p.log.Debug("finish work", zap.Uint32("amount of unfinished replicas", task.quantity), diff --git a/pkg/services/replicator/task.go b/pkg/services/replicator/task.go index 3d9da9b6bf..31347362d8 100644 --- a/pkg/services/replicator/task.go +++ b/pkg/services/replicator/task.go @@ -17,38 +17,22 @@ type Task struct { nodes []netmap.NodeInfo } -// WithCopiesNumber sets number of copies to replicate. -func (t *Task) WithCopiesNumber(v uint32) *Task { - if t != nil { - t.quantity = v - } - - return t +// SetCopiesNumber sets number of copies to replicate. +func (t *Task) SetCopiesNumber(v uint32) { + t.quantity = v } -// WithObjectAddress sets address of local object. -func (t *Task) WithObjectAddress(v oid.Address) *Task { - if t != nil { - t.addr = v - } - - return t +// SetObjectAddress sets address of local object. +func (t *Task) SetObjectAddress(v oid.Address) { + t.addr = v } -// 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 +// SetObject sets object to avoid fetching it from the local storage. +func (t *Task) SetObject(obj *objectSDK.Object) { + t.obj = obj } -// WithNodes sets a list of potential object holders. -func (t *Task) WithNodes(v []netmap.NodeInfo) *Task { - if t != nil { - t.nodes = v - } - - return t +// SetNodes sets a list of potential object holders. +func (t *Task) SetNodes(v []netmap.NodeInfo) { + t.nodes = v }