0x-infinity commented on code in PR #996:
URL:
https://github.com/apache/incubator-seata-go/pull/996#discussion_r2554151563
##########
pkg/datasource/sql/async_worker.go:
##########
@@ -123,7 +129,9 @@ func (aw *AsyncWorker) BranchCommit(ctx context.Context,
req rm.BranchResource)
}
func (aw *AsyncWorker) run() {
+ defer aw.wg.Done()
Review Comment:
Remove this line.
##########
pkg/datasource/sql/async_worker.go:
##########
@@ -68,6 +69,9 @@ type AsyncWorker struct {
doBranchCommitFailureTotal prometheus.Counter
receiveChanLength prometheus.Gauge
rePutBackToQueue prometheus.Counter
+
+ done chan struct{}
+ wg sync.WaitGroup
Review Comment:
The `done` channel and `wg` are not needed here.
##########
pkg/datasource/sql/async_worker.go:
##########
@@ -134,10 +142,18 @@ func (aw *AsyncWorker) run() {
}
case <-ticker.C:
aw.doBranchCommit(&phaseCtxs)
+ case <-aw.done:
+ return
}
}
}
+// Stop stops the AsyncWorker.
Review Comment:
Similarly, there is no need to add a new `Stop` method here.
##########
pkg/datasource/sql/async_worker.go:
##########
@@ -134,10 +142,18 @@ func (aw *AsyncWorker) run() {
}
case <-ticker.C:
aw.doBranchCommit(&phaseCtxs)
+ case <-aw.done:
Review Comment:
Just listen to `ctx.Done`.
##########
pkg/datasource/sql/async_worker.go:
##########
@@ -123,7 +129,9 @@ func (aw *AsyncWorker) BranchCommit(ctx context.Context,
req rm.BranchResource)
}
func (aw *AsyncWorker) run() {
Review Comment:
This run method is private, changing it to `run(ctx context.Context)` will
not affect the outside.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]