Skip to content

Commit

Permalink
rename masterchan to eventchan, retryNum -= 1 when error is retryable
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-chenzz committed Jan 22, 2024
1 parent 3cb4a91 commit 4a53211
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions common/bizflow/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (g *Graph) Run(ctx context.Context) error {
g.tryStop(it)
case RetryableError:
if it.retryNum > 0 {
it.retryNum -= 1
g.e.workPool.Submit(func() { g.work(it) })
}
case NonRetryable:
Expand Down Expand Up @@ -118,7 +119,7 @@ func (g *Graph) execNext(it *item) {
}
}
}
func (g *Graph) masterChanClosed() bool {
func (g *Graph) eventChanClosed() bool {
select {
case _, ok := <-g.eventChan:
return !ok
Expand All @@ -128,11 +129,11 @@ func (g *Graph) masterChanClosed() bool {
}
func (g *Graph) work(it *item) {
// 先检查一下
if g.masterChanClosed() {
if g.eventChanClosed() {
return
}
defer func() {
if !g.masterChanClosed() {
if !g.eventChanClosed() {
g.eventChan <- it
}
}()
Expand Down

0 comments on commit 4a53211

Please sign in to comment.