abra/pkg/web/client.go
decentral1se cb32e88cde
All checks were successful
continuous-integration/drone/push Build is passing
fix: support retryable http clients
Closes coop-cloud/organising#257.
2021-11-22 18:28:18 +01:00

24 lines
512 B
Go

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
}