Documentation ¶
Index ¶
- Constants
- Variables
- func B2s(b []byte) string
- func BackupAndCleanDir(dir string) error
- func CloseChan(c interface{}) (ret bool)
- func Exit(code int, msg string)
- func ExpandDir(dir string) string
- func GoID() (int, error)
- func GraphiteSplit(s string, lensep string, sep string) []string
- func IsDirEmpty(name string) bool
- func MkdirAll(path string) error
- func NextNumberPowerOf2(v uint64) uint64
- func Now() time.Time
- func NowUnixNano() int64
- func PanicToErr(f func(), err *error) (failed bool)
- func RemoveAll(path string) error
- func RemoveRepeatedByte(s string, needRemoveByte byte) string
- func S2b(s string) []byte
- func ScanTokens(str string, removeEscapeChar bool, visitor TokenVisitor) (string, error)
- func Since(t time.Time) time.Duration
- func SysProcAttr() *syscall.SysProcAttr
- func UUID() (string, error)
- func ValidateName(name string) error
- type ExpDecaySample
- func (s *ExpDecaySample) Close()
- func (s *ExpDecaySample) Count() int64
- func (s *ExpDecaySample) Max() int64
- func (s *ExpDecaySample) Min() int64
- func (s *ExpDecaySample) Percentile(q float64) float64
- func (s *ExpDecaySample) StdDev() float64
- func (s *ExpDecaySample) Sum() int64
- func (s *ExpDecaySample) Update(v int64)
- func (s *ExpDecaySample) Variance() float64
- type Lazybuf
- type NamedCallback
- type NamedCallbackSet
- type NumericAvgAggregator
- type NumericMaxAggregator
- type NumericMinAggregator
- type NumericSumAggregator
- type StatAggregator
- type StringRegexValue
- type TokenVisitor
- type Uint16RangeValue
- type Uint16Value
- type Uint32RangeValue
- type Uint32Value
- type Uint64RangeValue
- type Uint8Value
Constants ¶
const ( CallbacksInitCapacity = 20 NORMAL_PRIORITY_CALLBACK = "__NoRmAl_PrIoRiTy_CaLlBaCk" CRITICAL_PRIORITY_CALLBACK = "__CrItIcAl_PrIoRiTy_CaLlBaCk" )
const TOKEN_ESCAPE_CHAR string = `\`
Variables ¶
var ( TRUE_STRINGS = []string{"1", "t", "true", "on", "y", "yes"} FALSE_STRINGS = []string{"0", "f", "false", "off", "n", "no"} )
var URL_FRIENDLY_CHARACTERS_REGEX = regexp.MustCompile(`^[A-Za-z0-9\-_\.~]{1,253}$`)
safe characters for friendly url, rfc3986 section 2.3
Functions ¶
func B2s ¶
B2s converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
Note it may break if string and/or slice header will change in the future go versions.
func BackupAndCleanDir ¶
BackupAndCleanDir cleans old stuff in both dir and backupDir, and backups dir to backupDir. The backupDir generated by appending postfix `_bak` for dir. It does nothing if dir does not exist.
func ExpandDir ¶
ExpandDir cleans the dir, and returns itself if it's absolute, otherwise prefix with the current/working directory.
func GraphiteSplit ¶
GraphiteSplit slices s into all substrings separated by sep returns a slice of the substrings without length prefix separated by lensep. The routine does its best to split without error returned.
func IsDirEmpty ¶
func NextNumberPowerOf2 ¶
Via: https://stackoverflow.com/a/466242/1705845
https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
func NowUnixNano ¶
func NowUnixNano() int64
func PanicToErr ¶
func RemoveRepeatedByte ¶
func S2b ¶
S2b converts string to a byte slice without memory allocation.
Note it may break if string and/or slice header will change in the future go versions.
func ScanTokens ¶
func ScanTokens(str string, removeEscapeChar bool, visitor TokenVisitor) (string, error)
func SysProcAttr ¶
func SysProcAttr() *syscall.SysProcAttr
func ValidateName ¶
Types ¶
type ExpDecaySample ¶
type ExpDecaySample struct {
// contains filtered or unexported fields
}
func NewExpDecaySample ¶
func NewExpDecaySample(timeRange time.Duration, secondsForEachBucket int) *ExpDecaySample
func (*ExpDecaySample) Close ¶
func (s *ExpDecaySample) Close()
func (*ExpDecaySample) Count ¶
func (s *ExpDecaySample) Count() int64
func (*ExpDecaySample) Max ¶
func (s *ExpDecaySample) Max() int64
func (*ExpDecaySample) Min ¶
func (s *ExpDecaySample) Min() int64
func (*ExpDecaySample) Percentile ¶
func (s *ExpDecaySample) Percentile(q float64) float64
func (*ExpDecaySample) StdDev ¶
func (s *ExpDecaySample) StdDev() float64
func (*ExpDecaySample) Sum ¶
func (s *ExpDecaySample) Sum() int64
func (*ExpDecaySample) Update ¶
func (s *ExpDecaySample) Update(v int64)
func (*ExpDecaySample) Variance ¶
func (s *ExpDecaySample) Variance() float64
type Lazybuf ¶
type Lazybuf struct {
// contains filtered or unexported fields
}
A Lazybuf is a lazily constructed path buffer. It supports append, reading previously appended bytes, and retrieving the final string. It does not allocate a buffer to hold the output until that output diverges from s.
func NewLazybuf ¶
type NamedCallback ¶
type NamedCallback struct {
// contains filtered or unexported fields
}
func NewNamedCallback ¶
func NewNamedCallback(name string, callback interface{}) *NamedCallback
func (*NamedCallback) Callback ¶
func (cb *NamedCallback) Callback() interface{}
func (*NamedCallback) Name ¶
func (cb *NamedCallback) Name() string
func (*NamedCallback) SetCallback ¶
func (cb *NamedCallback) SetCallback(callback interface{}) interface{}
type NamedCallbackSet ¶
type NamedCallbackSet struct {
// contains filtered or unexported fields
}
func AddCallback ¶
func AddCallback(cbs *NamedCallbackSet, name string, callback interface{}, priority string) *NamedCallbackSet
func DeleteCallback ¶
func DeleteCallback(cbs *NamedCallbackSet, name string) *NamedCallbackSet
func NewNamedCallbackSet ¶
func NewNamedCallbackSet() *NamedCallbackSet
func (*NamedCallbackSet) CopyCallbacks ¶
func (cbs *NamedCallbackSet) CopyCallbacks() []*NamedCallback
func (*NamedCallbackSet) GetCallbacks ¶
func (cbs *NamedCallbackSet) GetCallbacks() []*NamedCallback
type NumericAvgAggregator ¶
type NumericAvgAggregator struct { NumericSumAggregator // contains filtered or unexported fields }
func (*NumericAvgAggregator) Aggregate ¶
func (a *NumericAvgAggregator) Aggregate(num interface{}) error
func (*NumericAvgAggregator) Result ¶
func (a *NumericAvgAggregator) Result() interface{}
func (*NumericAvgAggregator) String ¶
func (a *NumericAvgAggregator) String() string
type NumericMaxAggregator ¶
type NumericMaxAggregator struct {
// contains filtered or unexported fields
}
func (*NumericMaxAggregator) Aggregate ¶
func (a *NumericMaxAggregator) Aggregate(num interface{}) error
func (*NumericMaxAggregator) Result ¶
func (a *NumericMaxAggregator) Result() interface{}
func (*NumericMaxAggregator) String ¶
func (a *NumericMaxAggregator) String() string
type NumericMinAggregator ¶
type NumericMinAggregator struct {
// contains filtered or unexported fields
}
func (*NumericMinAggregator) Aggregate ¶
func (a *NumericMinAggregator) Aggregate(num interface{}) error
func (*NumericMinAggregator) Result ¶
func (a *NumericMinAggregator) Result() interface{}
func (*NumericMinAggregator) String ¶
func (a *NumericMinAggregator) String() string
type NumericSumAggregator ¶
type NumericSumAggregator struct {
// contains filtered or unexported fields
}
func (*NumericSumAggregator) Aggregate ¶
func (a *NumericSumAggregator) Aggregate(num interface{}) error
func (*NumericSumAggregator) Result ¶
func (a *NumericSumAggregator) Result() interface{}
func (*NumericSumAggregator) String ¶
func (a *NumericSumAggregator) String() string
type StatAggregator ¶
type StringRegexValue ¶
type StringRegexValue struct {
// contains filtered or unexported fields
}
func NewStringRegexValue ¶
func NewStringRegexValue(val string, p *string, r *regexp.Regexp) *StringRegexValue
func (*StringRegexValue) Get ¶
func (s *StringRegexValue) Get() interface{}
func (*StringRegexValue) Set ¶
func (s *StringRegexValue) Set(val string) error
func (*StringRegexValue) String ¶
func (s *StringRegexValue) String() string
type Uint16RangeValue ¶
type Uint16RangeValue struct {
// contains filtered or unexported fields
}
func NewUint16RangeValue ¶
func NewUint16RangeValue(val uint16, p *uint16, min, max uint16) *Uint16RangeValue
func (*Uint16RangeValue) Get ¶
func (i *Uint16RangeValue) Get() interface{}
func (*Uint16RangeValue) Set ¶
func (i *Uint16RangeValue) Set(s string) error
func (*Uint16RangeValue) String ¶
func (i *Uint16RangeValue) String() string
type Uint16Value ¶
type Uint16Value uint16
func NewUint16Value ¶
func NewUint16Value(val uint16, p *uint16) *Uint16Value
func (*Uint16Value) Get ¶
func (i *Uint16Value) Get() interface{}
func (*Uint16Value) Set ¶
func (i *Uint16Value) Set(s string) error
func (*Uint16Value) String ¶
func (i *Uint16Value) String() string
type Uint32RangeValue ¶
type Uint32RangeValue struct {
// contains filtered or unexported fields
}
func NewUint32RangeValue ¶
func NewUint32RangeValue(val uint32, p *uint32, min, max uint32) *Uint32RangeValue
func (*Uint32RangeValue) Get ¶
func (i *Uint32RangeValue) Get() interface{}
func (*Uint32RangeValue) Set ¶
func (i *Uint32RangeValue) Set(s string) error
func (*Uint32RangeValue) String ¶
func (i *Uint32RangeValue) String() string
type Uint32Value ¶
type Uint32Value uint32
func NewUint32Value ¶
func NewUint32Value(val uint32, p *uint32) *Uint32Value
func (*Uint32Value) Get ¶
func (i *Uint32Value) Get() interface{}
func (*Uint32Value) Set ¶
func (i *Uint32Value) Set(s string) error
func (*Uint32Value) String ¶
func (i *Uint32Value) String() string
type Uint64RangeValue ¶
type Uint64RangeValue struct {
// contains filtered or unexported fields
}
func NewUint64RangeValue ¶
func NewUint64RangeValue(val uint64, p *uint64, min, max uint64) *Uint64RangeValue
func (*Uint64RangeValue) Get ¶
func (i *Uint64RangeValue) Get() interface{}
func (*Uint64RangeValue) Set ¶
func (i *Uint64RangeValue) Set(s string) error
func (*Uint64RangeValue) String ¶
func (i *Uint64RangeValue) String() string
type Uint8Value ¶
type Uint8Value uint8
func NewUint8Value ¶
func NewUint8Value(val uint8, p *uint8) *Uint8Value
func (*Uint8Value) Get ¶
func (i *Uint8Value) Get() interface{}
func (*Uint8Value) Set ¶
func (i *Uint8Value) Set(s string) error
func (*Uint8Value) String ¶
func (i *Uint8Value) String() string