[core] Do not retry POST requests automatically

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-12-24 22:04:48 +01:00
parent 2ba462fedc
commit dbb9aae82a
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D

View File

@ -16,6 +16,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/Luzifer/go_helpers/v2/backoff"
"github.com/Luzifer/go_helpers/v2/str"
)
const (
@ -602,7 +603,14 @@ func (c *Client) request(opts clientRequestOpts) error {
"url": opts.URL,
}).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)
defer cancel()