Documentation
¶
Index ¶
- func AsInterfaceSlice[T any](in []T) []interface{}
- func DerefOr[T any](tp *T, fallback T) T
- func Max[T cmp.Ordered](i1 T, rest ...T) T
- func Min[T cmp.Ordered](i1 T, rest ...T) T
- func PartitionSliceByLength[T comparable](items []T, maxItems int) [][]T
- func PointerOf[T any](x interface{}) *T
- func Ref[T any](x T) *T
- func RefOrNil[T comparable](x T) *T
- func UnorderedDedupedCopy[T comparable](items []T) []T
- func ValueOr[T comparable](in T, fallback T) T
- func WithAttempts(attempts int, main func() error) error
- func WithBackoff(duration time.Duration, main func() error) func() error
- func WithBackoffCancelling(unit time.Duration, max time.Duration, main func() bool) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsInterfaceSlice ¶
func AsInterfaceSlice[T any](in []T) []interface{}
func DerefOr ¶
func DerefOr[T any](tp *T, fallback T) T
DerefOr returns value pointed by `tp` or the fallback supplied
func PartitionSliceByLength ¶
func PartitionSliceByLength[T comparable](items []T, maxItems int) [][]T
PartitionSliceByLength partitions a slice into multiple slices of up to `maxItems` size
func PointerOf ¶
func PointerOf[T any](x interface{}) *T
PointerOf performs a type-assertion to T and returns a pointer if successful, nil otherwise.
func RefOrNil ¶
func RefOrNil[T comparable](x T) *T
RefOrNil returns a pointer to the value supplied if it's not the default value, nil otherwise
func UnorderedDedupedCopy ¶
func UnorderedDedupedCopy[T comparable](items []T) []T
DedupeInNewSlice creates a new slice from `items` without duplicate elements
func ValueOr ¶
func ValueOr[T comparable](in T, fallback T) T
ValueOr returns the supplied value if it has something other than the default value for type T. Returns `fallback` otherwise
func WithAttempts ¶
WithAttempts executes a function N times or until no error is returned
func WithBackoff ¶
WithBackoff wraps the function to add Exponential backoff
Types ¶
This section is empty.