Documentation ¶
Index ¶
- func RecordMetrics(instance string, status int, duration time.Duration)
- func Retry(attempts int, sleep time.Duration, callbackFunc func() error) error
- func RetryStop(err error) error
- func UnmarshalJsonObj(key string, obj interface{}) (map[string]interface{}, error)
- func ValidKeys[T any](items []T, f func(T) string) bool
- type BoundedWaitGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
func RetryStop ¶
RetryStop wraps the given error in a private retryError type and returns it to signal that a retry loop should stop attempting the operation that produced the given error.
func UnmarshalJsonObj ¶
Yaml unmarshal limitation causes nested options objects to be decode as strings with json format ex: `{"foo": "bar"}` UnmarshalJsonObj performs unmarshal of jsons strings
Types ¶
type BoundedWaitGroup ¶
type BoundedWaitGroup struct {
// contains filtered or unexported fields
}
BoundedWaitGroup implements a sized WaitGroup
func NewBoundedWaitGroup ¶
func NewBoundedWaitGroup(cap int) BoundedWaitGroup
NewBoundedWaitGroup initializes a new BoundedWaitGroup
func (*BoundedWaitGroup) Add ¶
func (bwg *BoundedWaitGroup) Add(delta int)
Add performs a WaitGroup Add of a specified delta
func (*BoundedWaitGroup) Done ¶
func (bwg *BoundedWaitGroup) Done()
Done performs a WaitGroup Add of -1