utils

package
v0.0.0-...-f62d9cd Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateMemLimit

func CalculateMemLimit(maxMemRate float64) int

func GetCPULimitNum

func GetCPULimitNum(maxCPURate float64) int

func GetMetricPrimaryKey

func GetMetricPrimaryKey(endpoint, metric string, tags map[string]string) string

func Md5

func Md5(raw string) string

func ReformatMetricUniqueString

func ReformatMetricUniqueString(endpoint, metric string, tags map[string]string, dsType string, step int) string

func ReformatTag

func ReformatTag(str string) map[string]string

func SortedTags

func SortedTags(tags map[string]string) string

func UnixTsFormat

func UnixTsFormat(ts int64) string

Types

type List

type List struct {
	sync.RWMutex
	L *list.List
}

func NewSafeList

func NewSafeList() *List

func (*List) BackAll

func (u *List) BackAll() []interface{}

func (*List) Front

func (u *List) Front() interface{}

func (*List) FrontAll

func (u *List) FrontAll() []interface{}

func (*List) Len

func (u *List) Len() int

func (*List) PopBack

func (u *List) PopBack() interface{}

func (*List) PopBackAll

func (u *List) PopBackAll() []interface{}

func (*List) PopBackBy

func (u *List) PopBackBy(max int) []interface{}

func (*List) PushFront

func (u *List) PushFront(v interface{}) *list.Element

func (*List) PushFrontBatch

func (u *List) PushFrontBatch(vs []interface{})

func (*List) Remove

func (u *List) Remove(e *list.Element) interface{}

func (*List) RemoveAll

func (u *List) RemoveAll()

type ListLimited

type ListLimited struct {
	SL *List
	// contains filtered or unexported fields
}

SafeList with Limited Size

func NewSafeListLimited

func NewSafeListLimited(maxSize int) *ListLimited

func (*ListLimited) Front

func (u *ListLimited) Front() interface{}

func (*ListLimited) FrontAll

func (u *ListLimited) FrontAll() []interface{}

func (*ListLimited) Len

func (u *ListLimited) Len() int

func (*ListLimited) PopBack

func (u *ListLimited) PopBack() interface{}

func (*ListLimited) PopBackBy

func (u *ListLimited) PopBackBy(max int) []interface{}

func (*ListLimited) PushFront

func (u *ListLimited) PushFront(v interface{}) bool

func (*ListLimited) PushFrontBatch

func (u *ListLimited) PushFrontBatch(vs []interface{}) bool

func (*ListLimited) PushFrontViolently

func (u *ListLimited) PushFrontViolently(v interface{}) bool

func (*ListLimited) RemoveAll

func (u *ListLimited) RemoveAll()

type SafeSet

type SafeSet struct {
	sync.RWMutex
	M map[string]bool
}

func NewSafeSet

func NewSafeSet() *SafeSet

func (*SafeSet) Add

func (u *SafeSet) Add(key string)

func (*SafeSet) Clear

func (u *SafeSet) Clear()

func (*SafeSet) Contains

func (u *SafeSet) Contains(key string) bool

func (*SafeSet) Remove

func (u *SafeSet) Remove(key string)

func (*SafeSet) Size

func (u *SafeSet) Size() int

func (*SafeSet) ToSlice

func (u *SafeSet) ToSlice() []string

type Semaphore

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

func NewSemaphore

func NewSemaphore(concurrencyNum int) *Semaphore

func (*Semaphore) Acquire

func (u *Semaphore) Acquire()

func (*Semaphore) AvailablePermits

func (u *Semaphore) AvailablePermits() int

func (*Semaphore) Release

func (u *Semaphore) Release()

func (*Semaphore) TryAcquire

func (u *Semaphore) TryAcquire() bool

type StringSet

type StringSet struct {
	M map[string]struct{}
}

func NewStringSet

func NewStringSet() *StringSet

func (*StringSet) Add

func (u *StringSet) Add(elt string) *StringSet

func (*StringSet) Clear

func (u *StringSet) Clear()

func (*StringSet) Delete

func (u *StringSet) Delete(elt string)

func (*StringSet) Exists

func (u *StringSet) Exists(elt string) bool

func (*StringSet) ToSlice

func (u *StringSet) ToSlice() []string

Jump to

Keyboard shortcuts

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