fix: support retryable http clients
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Closes coop-cloud/organising#257.
This commit is contained in:
23
pkg/web/client.go
Normal file
23
pkg/web/client.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user