stat

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Avg

func Avg(iterator Iterator) float64

Avg 返回窗口平均值

func Count

func Count(iterator Iterator) float64

Count 返回窗口中的 key

func Max

func Max(iterator Iterator) float64

Max 返回窗口最大值

func Min

func Min(iterator Iterator) float64

Min 返回窗口最小值

func Sum

func Sum(iterator Iterator) float64

Sum 返回窗口所有值之和

Types

type Aggregation

type Aggregation interface {
	Min() float64
	Max() float64
	Avg() float64
	Sum() float64
}

Aggregation 聚合接口

type Bucket

type Bucket struct {
	Points []float64
	Count  int64
	// contains filtered or unexported fields
}

Bucket 桶对象

func (*Bucket) Add

func (b *Bucket) Add(offset int, val float64)

Add 根据偏移量增加val

func (*Bucket) Append

func (b *Bucket) Append(val float64)

Append 将给定值附加到存储桶中

func (*Bucket) Next

func (b *Bucket) Next() *Bucket

Next 返回下一个存储桶

func (*Bucket) Reset

func (b *Bucket) Reset()

Reset 清空桶

type Iterator

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

Iterator 迭代窗口中所有桶

func (*Iterator) Bucket

func (i *Iterator) Bucket() Bucket

Bucket 获取当前存储通

func (*Iterator) Next

func (i *Iterator) Next() bool

Next 返回 true 表示已经全部迭代完毕

type Metric

type Metric interface {
	// Add 将给定值添加到当前窗口
	Add(int64)

	// Value 获取当前值
	// 如果是 类型是 PointGauge, RollingCounter, RollingGauge
	// 返回窗口总和
	Value() int64
}

Metric 简单实现 度量标准软件包中度量标准的实现是:Counter, Gauge,PointGauge, RollingCounter and RollingGauge.

type RollingCounter

type RollingCounter interface {
	Metric
	Aggregation
	Timespan() int
	// Reduce 将缩减功能应用于窗口内的所有存储桶。
	Reduce(func(Iterator) float64) float64
}

RollingCounter 滚动窗口接口

func NewRollingCounter

func NewRollingCounter(size int, bucketDuration time.Duration) RollingCounter

NewRollingCounter 实例化 RollingCounter 方法

type RollingPolicy

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

RollingPolicy 基于持续时间的环形窗口的策略,随时间段移动存储桶偏移量。

func NewRollingPolicy

func NewRollingPolicy(window *Window, bucketDuration time.Duration) *RollingPolicy

NewRollingPolicy 实例化 RollingPolicy 对象

func (*RollingPolicy) Add

func (r *RollingPolicy) Add(val float64)

Add 将给定值添加到存储桶中的最新点

func (*RollingPolicy) Append

func (r *RollingPolicy) Append(val float64)

Append 将给定的点附加到窗口

func (*RollingPolicy) Reduce

func (r *RollingPolicy) Reduce(f func(Iterator) float64) (val float64)

Reduce 缩减应用窗口

type Window

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

Window Window 对象

func NewWindow

func NewWindow(size int) *Window

NewWindow 实例化 Window 对象

func (*Window) Add

func (w *Window) Add(offset int, val float64)

Add 将给定值添加到存储桶中索引等于给定偏移量的最新点

func (*Window) Append

func (w *Window) Append(offset int, val float64)

Append 将给定值附加到索引等于给定偏移量的存储桶。

func (*Window) Bucket

func (w *Window) Bucket(offset int) Bucket

Bucket 返回偏移量的窗口桶

func (*Window) Iterator

func (w *Window) Iterator(offset int, count int) Iterator

Iterator returns the bucket iterator.

func (*Window) ResetBucket

func (w *Window) ResetBucket(offset int)

ResetBucket 根据给定的偏移量清空存储桶。

func (*Window) ResetBuckets

func (w *Window) ResetBuckets(offsets []int)

ResetBuckets 根据给定的偏移量清空存储桶。

func (*Window) ResetWindow

func (w *Window) ResetWindow()

ResetWindow 清空窗口中的所有存储桶。

func (*Window) Size

func (w *Window) Size() int

Size 返回窗口小

Jump to

Keyboard shortcuts

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