mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-10 01:00:05 +00:00
[core] Do not retry POST requests automatically
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
2ba462fedc
commit
dbb9aae82a
1 changed files with 9 additions and 1 deletions
|
@ -16,6 +16,7 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/Luzifer/go_helpers/v2/backoff"
|
"github.com/Luzifer/go_helpers/v2/backoff"
|
||||||
|
"github.com/Luzifer/go_helpers/v2/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -602,7 +603,14 @@ func (c *Client) request(opts clientRequestOpts) error {
|
||||||
"url": opts.URL,
|
"url": opts.URL,
|
||||||
}).Trace("Execute Twitch API request")
|
}).Trace("Execute Twitch API request")
|
||||||
|
|
||||||
return backoff.NewBackoff().WithMaxIterations(twitchRequestRetries).Retry(func() error {
|
var retries uint64 = twitchRequestRetries
|
||||||
|
if str.StringInSlice(opts.Method, []string{
|
||||||
|
http.MethodPost, // Creates stuff, must not be retried without being asked
|
||||||
|
}) {
|
||||||
|
retries = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return backoff.NewBackoff().WithMaxIterations(retries).Retry(func() error {
|
||||||
reqCtx, cancel := context.WithTimeout(opts.Context, twitchRequestTimeout)
|
reqCtx, cancel := context.WithTimeout(opts.Context, twitchRequestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue