utils

package
v0.0.0-...-8d187f3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ORG_ID_INDEX_MAX = common.ORG_ID_MAX + 1 // 0 index not used

Variables

This section is empty.

Functions

func CheckOrgID

func CheckOrgID(orgID int) bool

func Concat

func Concat[S ~[]E, E any](slices ...S) S

func ConvertStrToU32List

func ConvertStrToU32List(convertStr string) ([]uint32, error)

func Find

func Find[T Number](slice []T, val T) bool

func GetWaitGroupInCtx

func GetWaitGroupInCtx(ctx context.Context) *sync.WaitGroup

func Grow

func Grow[S ~[]E, E any](s S, n int) S

func IsVMofBMHtype

func IsVMofBMHtype(htype int) bool

func Lookup

func Lookup(host net.IP) (net.IP, error)

func MacStrToU64

func MacStrToU64(mac string) (uint64, error)

func MaxTime

func MaxTime(t1 time.Time, t2 time.Time) time.Time

func NewWaitGroupCtx

func NewWaitGroupCtx() (context.Context, context.CancelFunc)

func SliceEqual

func SliceEqual[T Number](a, b []T) bool

Types

type Counter

type Counter struct {
	Max     int `statsd:"max-bucket"`
	Size    int `statsd:"size"`
	AvgScan int `statsd:"avg-scan"` // 平均扫描次数
	// contains filtered or unexported fields
}

type KeyValue

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

func (KeyValue) GetData

func (k KeyValue) GetData() (uint64, uint64, interface{})

type Number

type Number interface {
	~int | ~string | uint32
}

type ORGID

type ORGID int

func (ORGID) GetORGID

func (o ORGID) GetORGID() int

func (ORGID) Log

func (o ORGID) Log(logStr string) (string, logger.Prefix)

func (ORGID) Logf

func (o ORGID) Logf(format string, args ...interface{}) (string, logger.Prefix)

type U128IDMap

type U128IDMap struct {
	utils.Closable
	// contains filtered or unexported fields
}

注意:不是线程安全的

func NewU128IDMap

func NewU128IDMap(module string, hashSlots uint32, opts ...stats.OptionStatTags) *U128IDMap

func NewU128IDMapNoStats

func NewU128IDMapNoStats(module string, hashSlots uint32) *U128IDMap

func (*U128IDMap) AddOrGet

func (m *U128IDMap) AddOrGet(key0, key1 uint64, value interface{}, overwrite bool) (interface{}, bool)

第一个返回值表示value,第二个返回值表示是否进行了Add。若key已存在,指定overwrite=true可覆写value。

func (*U128IDMap) AddOrGetWithSlice

func (m *U128IDMap) AddOrGetWithSlice(key []byte, _ uint32, value interface{}, overwrite bool) (interface{}, bool)

func (*U128IDMap) Clear

func (m *U128IDMap) Clear()

func (*U128IDMap) Close

func (m *U128IDMap) Close() error

func (*U128IDMap) Get

func (m *U128IDMap) Get(key0, key1 uint64) (interface{}, bool)

func (*U128IDMap) GetCollisionChain

func (m *U128IDMap) GetCollisionChain() []byte

func (*U128IDMap) GetCounter

func (m *U128IDMap) GetCounter() interface{}

func (*U128IDMap) GetWithSlice

func (m *U128IDMap) GetWithSlice(key []byte, _ uint32) (interface{}, bool)

func (*U128IDMap) ID

func (m *U128IDMap) ID() string

func (*U128IDMap) Iter

func (m *U128IDMap) Iter() <-chan KeyValue

func (*U128IDMap) KeySize

func (m *U128IDMap) KeySize() int

func (*U128IDMap) NoStats

func (m *U128IDMap) NoStats() *U128IDMap

func (*U128IDMap) SetCollisionChainDebugThreshold

func (m *U128IDMap) SetCollisionChainDebugThreshold(t int)

func (*U128IDMap) Size

func (m *U128IDMap) Size() int

func (*U128IDMap) Width

func (m *U128IDMap) Width() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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