util

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndCondition

func AndCondition(execs ...func() bool) bool

func Atoi

func Atoi(b []byte) (int, error)

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string.

func CronWithCtx

func CronWithCtx(ctx context.Context, duration time.Duration, fn func(context.Context))

func GetStackStringBySize

func GetStackStringBySize(size int) []byte

func PanicIfErr

func PanicIfErr(err error, appendErrs ...error)

func ParseFloat

func ParseFloat(b []byte, bitSize int) (float64, error)

func ParseInt

func ParseInt(b []byte, base int, bitSize int) (int64, error)

func ParseUint

func ParseUint(b []byte, base int, bitSize int) (uint64, error)

func RecoverCallback

func RecoverCallback(f func(e interface{}))

func Retry

func Retry(f func() error, times int) (err error)

func RetryExponential

func RetryExponential(ctx context.Context, f func() error, times uint, scalar time.Duration) (err error)

The scalar is multiplied times 2 raised to the current attempt.

func RetryLinearJitter

func RetryLinearJitter(ctx context.Context, f func() error, times int, waitBetween time.Duration, jitterFraction float64) (err error)

waitBetween=1s and jitter=0.10 can generate waits between 900ms and 1100ms.

func StopWithCtx

func StopWithCtx(ctx context.Context, stopFn func())

func StopWithTimeout

func StopWithTimeout(stopFn func(), timeout time.Duration)

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice.

func VersionEq

func VersionEq(a, b string, semantic VersionSemantic) bool

func VersionGE

func VersionGE(a, b string, semantic VersionSemantic) bool

>=

func VersionLE

func VersionLE(a, b string, semantic VersionSemantic) bool

func Xrecover

func Xrecover(err *error, appendErrs ...error)

Types

type FuncStack

type FuncStack struct {
	Frames []*FuncStackFrame
}

func GetCallerStack

func GetCallerStack(skip, depth int) FuncStack

func (*FuncStack) String

func (s *FuncStack) String() string

func (*FuncStack) StringOneLine

func (s *FuncStack) StringOneLine() string

type FuncStackFrame

type FuncStackFrame struct {
	FuncName string
	File     string
	Line     int
}

func GetCallerStackFrame

func GetCallerStackFrame(skip int) *FuncStackFrame

func (*FuncStackFrame) String

func (r *FuncStackFrame) String() string

type OpenCircuitExec

type OpenCircuitExec struct {
	// contains filtered or unexported fields
}

func (*OpenCircuitExec) Do

func (sce *OpenCircuitExec) Do(f func() error) error

type SliceBuffer

type SliceBuffer struct {
	// contains filtered or unexported fields
}

func NewSliceBuffer

func NewSliceBuffer(s []byte) *SliceBuffer

func (*SliceBuffer) Read

func (s *SliceBuffer) Read(b []byte) int

func (*SliceBuffer) Read1

func (s *SliceBuffer) Read1(b []byte) (int, error)

func (*SliceBuffer) ReadByte

func (s *SliceBuffer) ReadByte() byte

func (*SliceBuffer) ReadByte1

func (s *SliceBuffer) ReadByte1() (byte, error)

func (*SliceBuffer) ReadUint16

func (s *SliceBuffer) ReadUint16() uint16

func (*SliceBuffer) ReadUint24

func (s *SliceBuffer) ReadUint24() uint32

func (*SliceBuffer) ReadUint32

func (s *SliceBuffer) ReadUint32() uint32

func (*SliceBuffer) ReadUint64

func (s *SliceBuffer) ReadUint64() uint64

func (*SliceBuffer) Seek

func (s *SliceBuffer) Seek(offset int64, whence int) int64

func (*SliceBuffer) Slice

func (s *SliceBuffer) Slice(n int) []byte

func (*SliceBuffer) Slice1

func (s *SliceBuffer) Slice1(n int) ([]byte, error)

type VersionSemantic

type VersionSemantic int
const (
	VersionMajor VersionSemantic = 0
	VersionMinor VersionSemantic = 1
	VersionPatch VersionSemantic = 2
)

Jump to

Keyboard shortcuts

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