in internal/components/trigger/http.go [69:97]
func (h *httpAction) Do() chan error {
t := time.NewTicker(h.interval)
logger.Log.Infof("trigger will request URL %s %d times with interval %s.", h.url, h.times, h.interval)
result := make(chan error)
sent := false
go func() {
for {
select {
case <-t.C:
err := h.execute()
// `err == nil`: if no error occurs, everything is OK and send `nil` to the channel to continue.
// `h.times == h.executedCount`: reach to the maximum retry count and send the `err`, no matter it's `nil` or not.
if !sent && (err == nil || h.times == h.executedCount) {
result <- err
sent = true
}
case <-h.stopCh:
t.Stop()
result <- nil
return
}
}
}()
return result
}