common

package
v4.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsFloat64OrNil

func AsFloat64OrNil(data interface{}) *float64

AsFloat64OrNil return ref

func AsInt64OrNil

func AsInt64OrNil(data interface{}) *int64

AsInt64OrNil returns ref

func AsIntOrNil

func AsIntOrNil(data interface{}) *int

AsIntOrNil returns ref

func AsStringOrNil

func AsStringOrNil(data interface{}) *string

AsStringOrNil returns ref

func Float64Ref

func Float64Ref(number float64) *float64

Float64Ref returns ref

func Int64FromRef

func Int64FromRef(number *int64) int64

Int64FromRef returns value

func Int64Ref

func Int64Ref(number int64) *int64

Int64Ref returns ref

func Int64RefOrNil

func Int64RefOrNil(number int64) *int64

Int64RefOrNil returns ref

func Int64Value

func Int64Value(number *int64) int64

Int64Value kept to prevent breaking change. TODO: Deprecate in v4

func IntFromRef

func IntFromRef(ref *int) int

IntFromRef returns 0 if nil, dereferenced value otherwhise.

func IntRef

func IntRef(number int) *int

IntRef returns ref

func IntRefOrNil

func IntRefOrNil(number int) *int

IntRefOrNil returns ref

func MaxDuration

func MaxDuration(d1, d2 time.Duration, ds ...time.Duration) time.Duration

MaxDuration returns the max duration among them

func MinDuration

func MinDuration(d1, d2 time.Duration, ds ...time.Duration) time.Duration

MinDuration returns the min duration among them

func Partition

func Partition(items []string, maxItems int) [][]string

Partition create partitions considering the passed amount

func StringFromRef

func StringFromRef(str *string) string

StringFromRef returns original value if not empty. Default otherwise.

func StringRef

func StringRef(str string) *string

StringRef returns ref

func StringRefOrNil

func StringRefOrNil(str string) *string

StringRefOrNil returns ref

func StringValueOrDefault

func StringValueOrDefault(str string, def string) string

StringValueOrDefault returns original value if not empty. Default otherwise.

func WithAttempts

func WithAttempts(attempts int, main func() error) error

WithAttempts executes a function N times or until no error is returned

func WithBackoff

func WithBackoff(duration time.Duration, main func() error) func() error

WithBackoff wraps the function to add Exponential backoff

func WithBackoffCancelling

func WithBackoffCancelling(unit time.Duration, max time.Duration, main func() bool) func()

WithBackoffCancelling wraps the function to add Exponential backoff

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL