Skip to content

Commit 53e3836

Browse files
committed
fix(rule): only transit in eof
Signed-off-by: Jiyong Huang <huangjy@emqx.io>
1 parent 910e1c0 commit 53e3836

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/topo/rule/state.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ func (s *State) doStop() error {
477477
return nil
478478
}
479479

480+
const EOFMessage = "done"
481+
480482
// This is called async
481483
func (s *State) runTopo(ctx context.Context, tp *topo.Topo, rs *def.RestartStrategy) {
482484
err := infra.SafeRun(func() error {
@@ -495,7 +497,7 @@ func (s *State) runTopo(ctx context.Context, tp *topo.Topo, rs *def.RestartStrat
495497
tp.Cancel()
496498
} else { // exit normally
497499
if errorx.IsEOF(er) {
498-
s.lastWill = "done"
500+
s.lastWill = EOFMessage
499501
s.updateTrigger(s.Rule.Id, false)
500502
}
501503
tp.Cancel()
@@ -544,7 +546,7 @@ func (s *State) runTopo(ctx context.Context, tp *topo.Topo, rs *def.RestartStrat
544546
if err != nil { // Exit after retries
545547
s.logger.Error(err)
546548
s.transit(StoppedByErr, err)
547-
} else if s.lastWill != "" {
549+
} else if s.lastWill == EOFMessage {
548550
// Two case when err is nil; 1. Manually stop 2.EOF
549551
// Only transit status when EOF. Don't do this for manual stop because the state already changed!
550552
s.transit(Stopped, nil)

0 commit comments

Comments
 (0)