{"modulePath":"github.com/dockerstack/amazon-ecs-agent","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Functions\n\n```go\nfunc AddJitter(duration time.Duration, jitter time.Duration) time.Duration\n```\nAddJitter adds an amount of jitter between 0 and the given jitter to the given duration\n\n```go\nfunc CompleteJsonUnmarshal(b []byte, iface interface{}) error\n```\nCompleteJsonUnmarshal determines if a given struct has members corresponding to every key of a json object (passed as the json string). By default, Go ignores fields in an object which have no corresponding struct member and this can be used to determine if this ignoring has occured Errors will result in \"false\" as a return value\n\n```go\nfunc DefaultIfBlank(str string, default_value string) string\n```\n\n```go\nfunc JsonKeys(b []byte) ([]string, error)\n```\nJsonKeys takes an arbitrary byte array representing a json stringified object and returns all the keys of that object.\n\n```go\nfunc NewMultiError(errs ...error) error\n```\n\n```go\nfunc ParseBool(str string, default_ bool) bool\n```\n\n```go\nfunc RandHex() string\n```\n\n```go\nfunc RetryNWithBackoff(backoff Backoff, n int, fn func() error) error\n```\nRetryNWithBackoff takes a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until either it does not return an error or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.\n\n```go\nfunc RetryWithBackoff(backoff Backoff, fn func() error) error\n```\nRetryWithBackoff takes a Backoff and a function to call that returns an error If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried\n\n```go\nfunc SlicesDeepEqual(slice1, slice2 interface{}) bool\n```\nSlicesDeepEqual checks if slice1 and slice2 are equal, disregarding order.\n\n```go\nfunc StrSliceEqual(s1, s2 []string) bool\n```\n\n```go\nfunc Strptr(s string) *string\n```\n\n```go\nfunc Uint16SliceToStringSlice(slice []uint16) []*string\n```\nUint16SliceToStringSlice converts a slice of type uint16 to a slice of type \\*string. It uses strconv.Itoa on each element\n\n```go\nfunc ZeroOrNil(obj interface{}) bool\n```\n\n## Types\n\n```go\ntype Backoff interface {\n\tReset()\n\tDuration() time.Duration\n}\n```\n\n```go\ntype ChanSemaphore struct {\n\tCount int // Public for introspection; should not be written to\n\t// contains filtered or unexported fields\n}\n```\nImplements semaphore\n\n```go\nfunc (s *ChanSemaphore) Post()\n```\n\n```go\nfunc (s *ChanSemaphore) Wait()\n```\n\n```go\ntype DefaultRetriable struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (dr DefaultRetriable) Retry() bool\n```\n\n```go\ntype DefaultRetriableError struct {\n\tRetriable\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype MultiErr struct {\n\t// contains filtered or unexported fields\n}\n```\nImplements error\n\n```go\nfunc (me MultiErr) Error() string\n```\n\n```go\ntype Retriable interface {\n\tRetry() bool\n}\n```\n\n```go\nfunc NewRetriable(retry bool) Retriable\n```\n\n```go\ntype RetriableError interface {\n\tRetriable\n\terror\n}\n```\n\n```go\nfunc NewRetriableError(retriable Retriable, err error) RetriableError\n```\n\n```go\ntype Semaphore interface {\n\tPost()\n\tWait()\n}\n```\n\n```go\nfunc NewSemaphore(count int) Semaphore\n```\n\n```go\ntype SimpleBackoff struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSimpleBackoff(min, max time.Duration, jitterMultiple, multiple float64) *SimpleBackoff\n```\nNewSimpleBackoff creates a Backoff which ranges from min to max increasing by multiple each time. It also adds (and yes, the jitter is always added, never subtracted) a random amount of jitter up to jitterMultiple percent (that is, jitterMultiple = 0.0 is no jitter, 0.15 is 15% added jitter). The total time may exceed \"max\" when accounting for jitter, such that the absolute max is max + max \\* jiterMultiple\n\n```go\nfunc (sb *SimpleBackoff) Duration() time.Duration\n```\n\n```go\nfunc (sb *SimpleBackoff) Reset()\n```\n\n","path":"github.com/dockerstack/amazon-ecs-agent/agent/utils","name":"utils","synopsis":"","isRedistributable":true}
