代码拉取完成,页面将自动刷新
package metric
var _ Metric = &pointGauge{}
var _ Aggregation = &pointGauge{}
// PointGauge represents a ring window.
// Every buckets within the window contains one point.
// When the window is full, the earliest point will be overwrite.
type PointGauge interface {
Aggregation
Metric
// Reduce applies the reduction function to all buckets within the window.
Reduce(func(Iterator) float64) float64
}
// PointGaugeOpts contains the arguments for creating PointGauge.
type PointGaugeOpts struct {
// Size represents the bucket size within the window.
Size int
}
type pointGauge struct {
policy *PointPolicy
}
// NewPointGauge creates a new PointGauge based on PointGaugeOpts.
func NewPointGauge(opts PointGaugeOpts) PointGauge {
window := NewWindow(WindowOpts{Size: opts.Size})
policy := NewPointPolicy(window)
return &pointGauge{
policy: policy,
}
}
func (r *pointGauge) Add(val int64) {
r.policy.Append(float64(val))
}
func (r *pointGauge) Reduce(f func(Iterator) float64) float64 {
return r.policy.Reduce(f)
}
func (r *pointGauge) Avg() float64 {
return r.policy.Reduce(Avg)
}
func (r *pointGauge) Min() float64 {
return r.policy.Reduce(Min)
}
func (r *pointGauge) Max() float64 {
return r.policy.Reduce(Max)
}
func (r *pointGauge) Sum() float64 {
return r.policy.Reduce(Sum)
}
func (r *pointGauge) Value() int64 {
return int64(r.Sum())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。