Documentation ¶
Overview ¶
Package util has code that does not fit anywhere else
Index ¶
- func Contains(s []string, e string) bool
- func EnsureViperSub(viper *viper.Viper, key string) *viper.Viper
- func Log() *zap.SugaredLogger
- func NewHTTPTestServer(handlerFunc func(w http.ResponseWriter, r *http.Request)) *httptest.Server
- func NoopLog() *zap.SugaredLogger
- func ReadKeyFile(t *testing.T, fileName string) []byte
- func Retry(attempts int, sleep time.Duration, callbackFunc func() error) error
- func RetryStop(err error) error
- func StrPointer(s string) *string
- type AuthedTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureViperSub ¶
EnsureViperSub will return a viper sub if available or create one
func Log ¶
func Log() *zap.SugaredLogger
Log returns the SuggardLoggar that can be used accross integrations
func NewHTTPTestServer ¶
NewHTTPTestServer returns a new httptest.Server with a given handlerFunc
func NoopLog ¶
func NoopLog() *zap.SugaredLogger
NoopLog returns a no-op logger, that can be used to supress logging
func ReadKeyFile ¶
ReadKeyFile reads a key file and returns the content
func Retry ¶
Retry attempts to execute the given callback function a certain number of times, with a delay between each attempt using a simple exponential backoff algorithm that uses a slight jitter to ensure that retries aren't clustered.
If the callback function returns an error, Retry will sleep for a certain duration before attempting to call the callback function again.
Retry will repeat this process until the callback function succeeds or until the maximum number of attempts is reached.
If the maximum number of attempts is reached and the callback function still fails, it returns the last error returned by the callback function.
Types ¶
type AuthedTransport ¶
type AuthedTransport struct { Key string Wrapped http.RoundTripper }
AuthedTransport is a http.RoundTripper that adds an Authorization header