utils

package
v0.0.0-...-210eeb1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

AtomicIdGen

most reference from github.com/realint/dbgutil

idgen

Index

Constants

This section is empty.

Variables

View Source
var AdminCheckList map[string]HealthChecker
View Source
var Char_Buff = [26]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
	"t", "u", "v", "w", "x", "y", "z"}
View Source
var MinMaxError = errors.New("Min cannot be greater than max.")

Functions

func AddHealthCheck

func AddHealthCheck(name string, hc HealthChecker)

func AppendEmptySliceField

func AppendEmptySliceField(slice reflect.Value) reflect.Value

func Avg

func Avg(items []time.Duration) time.Duration

func CatchPanic

func CatchPanic(f func()) (err interface{})

func Clone

func Clone(src interface{}) (dst interface{})

unsupport [Complex64,Complex128,Chan,Func,Interface,UnsafePointer]

func DeleteEmptySliceElements

func DeleteEmptySliceElements(slice interface{}) interface{}

func DeleteEmptySliceElementsVal

func DeleteEmptySliceElementsVal(sliceVal reflect.Value) reflect.Value

func DeleteSliceElement

func DeleteSliceElement(slice interface{}, idx int) interface{}

func DeleteSliceElementVal

func DeleteSliceElementVal(sliceVal reflect.Value, idx int) reflect.Value

func Display

func Display(data ...interface{})

print the data in console

func DumpStack

func DumpStack(f string)

func DumpStackIfPanic

func DumpStackIfPanic(f string)

func GetCallStack

func GetCallStack() string

func GetDisplayString

func GetDisplayString(data ...interface{}) string

return string

func GetPanicStats

func GetPanicStats() map[string]PanicStackInfo

func IntRange

func IntRange(min, max int) (int, error)

func MemProf

func MemProf()

func PrintGCSummary

func PrintGCSummary(w io.Writer)

func ProcessInput

func ProcessInput(input string, w io.Writer)

func RandChoice

func RandChoice(choices []interface{}) (interface{}, error)

func RandCode

func RandCode(codelen int) string

func RandNumCode

func RandNumCode(codelen int) string

func RepeatUntilPanicless

func RepeatUntilPanicless(f func())

func RunPanicless

func RunPanicless(f func()) (panicless bool)

func SetSliceLengh

func SetSliceLengh(slice reflect.Value, length int) reflect.Value

func SortInterfaceSlice

func SortInterfaceSlice(slice []interface{}, lessFunc func(a, b interface{}) bool)

func StartCPUProfile

func StartCPUProfile()

func StopCPUProfile

func StopCPUProfile()

func ToH

func ToH(bytes uint64) string

human readable format

func ToS

func ToS(d time.Duration) string

short string format

Types

type AtomicIdGen

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

func (*AtomicIdGen) CurrId

func (this *AtomicIdGen) CurrId() uint32

func (*AtomicIdGen) NextId

func (this *AtomicIdGen) NextId() uint32

func (*AtomicIdGen) Reset

func (this *AtomicIdGen) Reset()

func (*AtomicIdGen) SetStartPoint

func (this *AtomicIdGen) SetStartPoint(startPoint uint32)

type HealthChecker

type HealthChecker interface {
	Check() error
}

type HealthCheckerWrapper

type HealthCheckerWrapper func() error

func (HealthCheckerWrapper) Check

func (hcw HealthCheckerWrapper) Check() error

type IdGen

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

func (*IdGen) CurrId

func (this *IdGen) CurrId() int

func (*IdGen) NextId

func (this *IdGen) NextId() int

func (*IdGen) Reset

func (this *IdGen) Reset()

func (*IdGen) SetSeq

func (this *IdGen) SetSeq(seq int)

func (*IdGen) SetStartPoint

func (this *IdGen) SetStartPoint(startPoint int)

type PanicStackInfo

type PanicStackInfo struct {
	FirstTime time.Time
	LastTime  time.Time
	Times     int64
	ErrorMsg  string
	StackBuf  string
}

type PanicStackMgr

type PanicStackMgr struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type RuntimeStats

type RuntimeStats struct {
	CountGoroutine int
	CountHeap      int
	CountThread    int
	CountBlock     int
}

func StatsRuntime

func StatsRuntime() RuntimeStats

type SortableInterfaceSlice

type SortableInterfaceSlice struct {
	Slice    []interface{}
	LessFunc func(a, b interface{}) bool
}

Implements sort.Interface

func (*SortableInterfaceSlice) Len

func (self *SortableInterfaceSlice) Len() int

func (*SortableInterfaceSlice) Less

func (self *SortableInterfaceSlice) Less(i, j int) bool

func (*SortableInterfaceSlice) Sort

func (self *SortableInterfaceSlice) Sort()

func (*SortableInterfaceSlice) Swap

func (self *SortableInterfaceSlice) Swap(i, j int)

type Waitor

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

func NewWaitor

func NewWaitor(name string) *Waitor

func (*Waitor) Add

func (w *Waitor) Add(name string, delta int)

func (*Waitor) Done

func (w *Waitor) Done(name string)

func (*Waitor) Wait

func (w *Waitor) Wait(name string)

Jump to

Keyboard shortcuts

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