Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRoundTripper ¶
func NewRoundTripper(config Config) (http.RoundTripper, error)
NewRoundTripper returns a new http.RoundTripper with retry behaviour.
Types ¶
type Config ¶
type Config struct {
BaseClient *http.Client
// BaseTransport allows to specify a base http.RoundTripper.
BaseTransport http.RoundTripper
// Logger allows to specify a custom logger. *slog.Logger will satisfy this.
Logger Logger
// NextRetryInSecondsFunc allows to specify a custom retry function.
// By default, exponential fibonacci like function is used.
NextRetryInSecondsFunc NextRetryInSeconds
// MaxRetries allows to specify the number of max retries before returning a fatal error.
// 5 is the default.
MaxRetries uint
// RetryableStatusCodes allows to specify the retryable status codes.
// defaultRetryableStatusCodes are the default.
RetryableStatusCodes map[int]struct{}
// AcceptedStatusCodes allows to specify the non-retryable status codes.
// defaultAcceptedStatusCodes are the default.
AcceptedStatusCodes map[int]struct{}
// ResponseInfoLoggerFunc when set will be used to check the response
// returned by the API
ResponseInfoLoggerFunc ResponseInfoLogger
}
Config allows configuring the client.
type Logger ¶
type Logger interface {
Error(msg string, keysAndValues ...any)
Info(msg string, keysAndValues ...any)
Debug(msg string, keysAndValues ...any)
Warn(msg string, keysAndValues ...any)
}
Logger allows to inject a custom logger in the client.
type NextRetryInSeconds ¶
NextRetryInSeconds allows customising the behaviour for the calculating the next retry.
type ResponseInfoLogger ¶ added in v0.0.4
ResponseInfoLogger is allowed to inspect the retryable response and print more info about it that might be useful to the caller for debugging
Click to show internal directories.
Click to hide internal directories.