Documentation
¶
Overview ¶
Package util is the dumping ground for helper functions without a good home.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArgListToMap ¶
func ArgListToMap(args ...interface{}) map[string]interface{}
ArgListToMap converts an argument list to a map, e.g. ("key", value, "key2", value2) => {"key": value, "key2", value2}
func CheckHTTPResponse ¶
CheckHTTPResponse does some basic error handling and reads the response body into a byte array
Types ¶
type IdleTimeout ¶
IdleTimeout provides a helper for managing the Pool's idle timeout. Start() and Stop() are used to control the timer, and Done() is used to detect when the timeout has been reached.
in := make(chan int) requestInput(in) t := IdleTimeoutAfter(time.Second * 10)
for {
select {
case <-t.Done():
// ... code to respond to timeout
case <-in:
// Reset the timeout.
t.Start()
}
}
func NewIdleTimeout ¶
func NewIdleTimeout(d time.Duration) IdleTimeout
NewIdleTimeout returns an IdleTimeout instance for the given duration.
func NoIdleTimeout ¶
func NoIdleTimeout() IdleTimeout
NoIdleTimeout creates an IdleTimeout that never times out.
type MultiError ¶
type MultiError []error
MultiError helps collect multiple errors and implements Go's "error" interface.
func (MultiError) Error ¶
func (m MultiError) Error() string
Error returns all the error strings joined by a newline.
func (MultiError) IsNil ¶
func (m MultiError) IsNil() bool
IsNil returns true if all errors in the slice are nil.
type Retrier ¶
type Retrier struct {
InitialInterval time.Duration
MaxInterval time.Duration
Multiplier float64
RandomizationFactor float64
MaxElapsedTime time.Duration
MaxTries int
ShouldRetry func(err error) bool
Notify func(err error, d time.Duration)
// contains filtered or unexported fields
}
Retrier is a wrapper around "github.com/cenkalti/backoff".ExponentialBackOff
func NewRetrier ¶
func NewRetrier() *Retrier
NewRetrier creates a new Retrier instance using default values.