0
0
forked from toolshed/abra

fix: support retryable http clients

Closes coop-cloud/organising#257.
This commit is contained in:
2021-11-22 18:28:18 +01:00
parent a18729bf98
commit cb32e88cde
6 changed files with 37 additions and 8 deletions

23
pkg/web/client.go Normal file
View File

@ -0,0 +1,23 @@
package web
import (
"fmt"
"github.com/hashicorp/go-retryablehttp"
"github.com/sirupsen/logrus"
)
type customLeveledLogger struct {
retryablehttp.Logger
}
func (l customLeveledLogger) Printf(msg string, args ...interface{}) {
logrus.Debugf(fmt.Sprintf(msg, args...))
}
// NewHTTPRetryClient instantiates a new http client with retries baked in
func NewHTTPRetryClient() *retryablehttp.Client {
retryClient := retryablehttp.NewClient()
retryClient.Logger = customLeveledLogger{}
return retryClient
}