forked from TrueCloudLab/frostfs-node
[#1621] services/tree: Return Apply
result asyncronously
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru> Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
ac81c70c09
commit
6efa93be0a
2 changed files with 34 additions and 7 deletions
|
@ -25,12 +25,33 @@ type replicationTask struct {
|
|||
req *ApplyRequest
|
||||
}
|
||||
|
||||
type applyOp struct {
|
||||
treeID string
|
||||
pilorama.CIDDescriptor
|
||||
pilorama.Move
|
||||
}
|
||||
|
||||
const (
|
||||
defaultReplicatorCapacity = 64
|
||||
defaultReplicatorWorkerCount = 64
|
||||
defaultReplicatorSendTimeout = time.Second * 5
|
||||
)
|
||||
|
||||
func (s *Service) localReplicationWorker() {
|
||||
for {
|
||||
select {
|
||||
case <-s.closeCh:
|
||||
return
|
||||
case op := <-s.replicateLocalCh:
|
||||
err := s.forest.TreeApply(op.CIDDescriptor, op.treeID, &op.Move, false)
|
||||
if err != nil {
|
||||
s.log.Error("failed to apply replicated operation",
|
||||
zap.String("err", err.Error()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) replicationWorker() {
|
||||
for {
|
||||
select {
|
||||
|
@ -74,6 +95,7 @@ func (s *Service) replicationWorker() {
|
|||
func (s *Service) replicateLoop(ctx context.Context) {
|
||||
for i := 0; i < s.replicatorWorkerCount; i++ {
|
||||
go s.replicationWorker()
|
||||
go s.localReplicationWorker()
|
||||
}
|
||||
defer func() {
|
||||
for len(s.replicationTasks) != 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue