From 6c96937059b928ee51d67a9d124aa2cf4270ab3e Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 21 Jan 2014 13:31:53 +0100 Subject: [PATCH] Async call url logs failures --- engine/action.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/action.go b/engine/action.go index fa6579032..a890d9dfa 100644 --- a/engine/action.go +++ b/engine/action.go @@ -196,11 +196,14 @@ func callUrlAsync(ub *UserBalance, a *Action) error { if err != nil { return err } - ubMarshal,_ := json.Marshal(ub) go func() { for i := 0; i < 5; i++ { // Loop so we can increase the success rate on best effort if _, err = http.Post(a.ExtraParameters, "application/json", bytes.NewBuffer(body)); err == nil { break // Success, no need to reinterate + } else if i == 4 { // Last iteration, syslog the warning + ubMarshal,_ := json.Marshal(ub) + Logger.Warning(fmt.Sprintf(" WARNING: Failed calling url: [%s], error: [%s], balance: %s", a.ExtraParameters, err.Error(), ubMarshal)) + break } time.Sleep(time.Duration(i) * time.Minute) }