Skip to content

Commit

Permalink
close ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed May 15, 2024
1 parent 218f40b commit b880d5b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/common/subscription/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import (
func ForwardFromChannels[R any](inputChannels []chan R, onMessage func(R) error, onBackendDisconnect func(), backendDisconnected *atomic.Bool, stopped *atomic.Bool, timeoutInterval time.Duration, logger gethlog.Logger) {
inputCases := make([]reflect.SelectCase, len(inputChannels)+1)

cleanupTicker := time.NewTicker(2 * time.Second)
defer cleanupTicker.Stop()
// create a ticker to handle cleanup, check the "stopped" flag and exit the goroutine
inputCases[0] = reflect.SelectCase{
Dir: reflect.SelectRecv,
Chan: reflect.ValueOf(time.NewTicker(2 * time.Second).C),
Chan: reflect.ValueOf(cleanupTicker.C),
}

// create a select "case" for each input channel
Expand Down

0 comments on commit b880d5b

Please sign in to comment.