util

package
v0.0.0-...-721af93 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIPs

func GetLocalIPs() ([]string, error)

GetLocalIPs return all the address

func GetMysqlConnectionInfo

func GetMysqlConnectionInfo(user string, password string, port uint16) (map[string]*DBConnectionInfo, error)

GetMysqlConnectionInfo return all db connection info

func Hash

func Hash(key string) string

Hash return the hash code of a string

func ReadLengthEncodedInteger

func ReadLengthEncodedInteger(b []byte) (uint64, bool, int)

ReadLengthEncodedInteger is a length decoder

func ReadStatus

func ReadStatus(b []byte) uint16

ReadStatus return the mysql reponse status

Types

type ConnectionWatcher

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

ConnectionWatcher get the connection info by db client and refresh periodically

func NewConnectionWatcher

func NewConnectionWatcher(uname, passward string, port uint16) *ConnectionWatcher

NewConnectionWatcher create a instance of connection watcher

func (*ConnectionWatcher) Get

Get return the connection info by key

type DBConnectionInfo

type DBConnectionInfo struct {
	ID, User, Host, DB, Cmd, Time, State, Info, Sent, Examined []byte
}

DBConnectionInfo retrieves the db connection info

type QuantileGroup

type QuantileGroup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

QuantileGroup caculate the 99 quantile, min and max

func NewQuantileGroup

func NewQuantileGroup(expiration time.Duration, size int) *QuantileGroup

NewQuantileGroup create a QuantileGroup

func (*QuantileGroup) Add

func (g *QuantileGroup) Add(key string, value int64)

Add record one point

func (*QuantileGroup) Get

func (g *QuantileGroup) Get(key string) (mint int64, max int64, q99 int64)

Get retrive min, max and q99

type RollingNumber

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

RollingNumber is struct for statistics

func NewRollingNumber

func NewRollingNumber(timeInMilliseconds, numberOfBuckets int64) (*RollingNumber, error)

NewRollingNumber create a new rolling number

func (*RollingNumber) Add

func (n *RollingNumber) Add(key string, val int64)

Add increase the counter specified by key with val

func (*RollingNumber) AverageInSecond

func (n *RollingNumber) AverageInSecond(key string) int64

AverageInSecond caculate the average of the item specified by key in second

func (*RollingNumber) Sum

func (n *RollingNumber) Sum(key string) int64

Sum return the sum of the counter sepecified by key

Jump to

Keyboard shortcuts

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