utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPort = 65535

Variables

View Source
var (
	RetryAnyError = func(_ error) bool {
		return true
	}
)

Functions

func BinaryExistsInPath

func BinaryExistsInPath(processName string) bool

func Bool2Int

func Bool2Int(b bool) int

func CatFile

func CatFile(filePath string, desc string)

func CheckOldMan

func CheckOldMan(version uint64, maxAge time.Duration) error

func Contains

func Contains(set map[string]struct{}, key string) bool

func ConvertToRelativePath

func ConvertToRelativePath(path string) string

func DeepCopyList

func DeepCopyList(in []string) (out []string)

func DirExists

func DirExists(dir string) bool

func FetchTimestampWithRetry

func FetchTimestampWithRetry(oracleFac oracle.Factory) (ts uint64, err error)

func FindAvailablePort

func FindAvailablePort(port int, isPortAvailable func(int) bool) int

func GenerateAllPossibleOrders

func GenerateAllPossibleOrders(array []string) [][]string

func GetCoordinatorName

func GetCoordinatorName(enableV3 bool) string

func GetLocalTimestamp

func GetLocalTimestamp() uint64

func GetLogLevel

func GetLogLevel() int

func IsDebug

func IsDebug() bool

func IsKilled

func IsKilled(err error) bool

func IsPortAvailable

func IsPortAvailable(port int) bool

func IsPowerOf2

func IsPowerOf2(x int) bool

func IsTerminated

func IsTerminated(err error) bool

func IsTooOld

func IsTooOld(version uint64, maxAge time.Duration) bool

func JsonDecode

func JsonDecode(v interface{}, b []byte) error

func JsonEncode

func JsonEncode(v interface{}) []byte

func JsonEncodeCompacted

func JsonEncodeCompacted(v interface{}) []byte

func MaxDuration

func MaxDuration(a, b time.Duration) time.Duration

func MaxInt

func MaxInt(a, b int) int

func MaxUint64

func MaxUint64(a, b uint64) uint64

func MinInt

func MinInt(a, b int) int

func MinUint64

func MinUint64(a, b uint64) uint64

func MkdirIfNotExists

func MkdirIfNotExists(dir string) error

func MustFetchTimestamp

func MustFetchTimestamp(oracleFac oracle.Factory) uint64

func NewBool

func NewBool(b bool) *bool

func NonInPlaceSort

func NonInPlaceSort(array []string) []string

func Now

func Now() *time.Time

func PrepareEmptyDir

func PrepareEmptyDir(dir string) error

func RandomKey

func RandomKey(length int) string

func RandomPeriod

func RandomPeriod(unit time.Duration, min, max int) time.Duration

func RandomSequence

func RandomSequence(n int) []int

func RandomShuffle

func RandomShuffle(seq []int)

func Range

func Range(n int) []int

func RemoveDirIfExists

func RemoveDirIfExists(dir string) error

func Set2StringList

func Set2StringList(m map[string]bool) []string

func SetCustomizedDebugFlag

func SetCustomizedDebugFlag(b bool)

func SetLogLevel

func SetLogLevel(v int) func()

func StringList2Set

func StringList2Set(keys []string) map[string]bool

func TrimmedSplit

func TrimmedSplit(str string, sep string) []string

func TryPort

func TryPort(port int) error

func Version

func Version() string

Version shows version thing

func VersionString

func VersionString(ver, rev, buildAt string) string

VersionString show version thing

func WithContextRetry

func WithContextRetry(ctx context.Context, interval, max int, f func(ctx context.Context) error) error

func WithContextRetryEx

func WithContextRetryEx(ctx context.Context, interval, timeout time.Duration, f func(ctx context.Context) error, isRetryable func(error) bool) error

func WithLogLevel

func WithLogLevel(v int, f func())

func WithRetry

func WithRetry(interval, max int, f func(ctx context.Context) error) error

WithRetry retries f() up to max number of times.

func WithSafeContextRetryEx

func WithSafeContextRetryEx(ctx context.Context, interval, timeout time.Duration, f func(ctx context.Context) error, isRetryable func(error) bool) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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