Documentation ¶
Overview ¶
Package util
Package util ¶
Package util ¶
Package util
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Now ¶
Now returns a relative time duration since initTime, which is not important. The caller only needs to care about the relative value.
func ProcessName ¶
func ProcessName() string
ProcessName returns the processname, same as the command name.
Types ¶
type Proba ¶
type Proba struct {
// contains filtered or unexported fields
}
A Proba is used to test if true on given probability.
func (*Proba) TrueOnProba ¶
TrueOnProba checks if true on given probability.
type RollingWindow ¶
type RollingWindow struct {
// contains filtered or unexported fields
}
RollingWindow defines a rolling window to calculate the events in buckets with time interval.
func NewRollingWindow ¶
func NewRollingWindow(size int, interval time.Duration, opts ...RollingWindowOption) *RollingWindow
NewRollingWindow returns a RollingWindow that with size buckets and time interval, use opts to customize the RollingWindow.
func (*RollingWindow) Add ¶
func (rw *RollingWindow) Add(v float64)
Add adds value to current bucket.
func (*RollingWindow) Reduce ¶
func (rw *RollingWindow) Reduce(fn func(b *Bucket))
Reduce runs fn on all buckets, ignore current bucket if ignoreCurrent was set.
type RollingWindowOption ¶
type RollingWindowOption func(rollingWindow *RollingWindow)
RollingWindowOption let callers customize the RollingWindow.
func IgnoreCurrentBucket ¶
func IgnoreCurrentBucket() RollingWindowOption
IgnoreCurrentBucket lets the Reduce call ignore current bucket.