Skip to content

Commit

Permalink
Add maxRetry limit in handleNextRetry
Browse files Browse the repository at this point in the history
  • Loading branch information
agourdel committed Jul 4, 2024
1 parent 96a391c commit 1f251d8
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions ee/webhooks/internal/components/webhook_collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,29 @@ func (c *Collector) handleSuccess(sAttempt *commons.SharedAttempt) {

func (c *Collector) handleNextRetry(sAttempt *commons.SharedAttempt) {
sAttempt.Val.NbTry += 1
commons.SetNextRetry(sAttempt.Val)
c.State.WaitingAttempts.Add(sAttempt)

go func() {
_, err := c.Database.UpdateAttemptNextTry(sAttempt.Val.ID, sAttempt.Val.NextTry, sAttempt.Val.LastHttpStatusCode)
if(c.RunnerParams.MaxRetry <= sAttempt.Val.NbTry ) {
commons.SetAbortMaxRetryStatus(sAttempt.Val)
_, err := c.Database.AbortAttempt(sAttempt.Val.ID, string(sAttempt.Val.Comment), false)
if err != nil {
message := fmt.Sprintf("Collector:handleNextRetry:Database.UpdateAttemptNextTry: %x", err)
message := fmt.Sprintf("Collector:handleNextRetry:Database.AbortAttempt: %x", err)
logging.Error(message)
panic(message)
}
}()
}else {

commons.SetNextRetry(sAttempt.Val)
c.State.WaitingAttempts.Add(sAttempt)

go func() {
_, err := c.Database.UpdateAttemptNextTry(sAttempt.Val.ID, sAttempt.Val.NextTry, sAttempt.Val.LastHttpStatusCode)
if err != nil {
message := fmt.Sprintf("Collector:handleNextRetry:Database.UpdateAttemptNextTry: %x", err)
logging.Error(message)
panic(message)
}
}()
}
}

func (c *Collector) handleMissingHook(sAttempt *commons.SharedAttempt) {
Expand Down

0 comments on commit 1f251d8

Please sign in to comment.