Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimeWindowAggregator ¶
type TimeWindowAggregator struct {
// contains filtered or unexported fields
}
TimeWindowAggregator wrappers sliding window to aggregate data.
It is concurrent-safe. It uses custom struct aggregator to aggregate data. The window is divided into several panes, and each pane's value is an aggregator instance.
func NewTimeWindowAggregator ¶
func NewTimeWindowAggregator(paneCount int, timeWindowSeconds int64) *TimeWindowAggregator
func (*TimeWindowAggregator) Add ¶
func (t *TimeWindowAggregator) Add(v float64)
Add adds a value to the sliding window's current pane.
func (*TimeWindowAggregator) Result ¶
func (t *TimeWindowAggregator) Result() *Result
Result returns the aggregate result of the sliding window by aggregating all panes.
type TimeWindowCounter ¶
type TimeWindowCounter struct {
// contains filtered or unexported fields
}
TimeWindowCounter wrappers sliding window around a counter.
It is concurrent-safe. When it works for calculating QPS, the counter's value means the number of requests in a pane.
func NewTimeWindowCounter ¶
func NewTimeWindowCounter(paneCount int, timeWindowSeconds int64) *TimeWindowCounter
func (*TimeWindowCounter) Add ¶
func (t *TimeWindowCounter) Add(step float64)
Add adds a step to the counter.
func (*TimeWindowCounter) Count ¶
func (t *TimeWindowCounter) Count() float64
Count returns the sum of all panes' value.
func (*TimeWindowCounter) LivedSeconds ¶
func (t *TimeWindowCounter) LivedSeconds() int64
LivedSeconds returns the lived seconds of the sliding window.
type TimeWindowQuantile ¶
type TimeWindowQuantile struct {
// contains filtered or unexported fields
}
TimeWindowQuantile wrappers sliding window around T-Digest.
It is concurrent safe. It uses T-Digest algorithm to calculate quantile. The window is divided into several panes, and each pane's value is a TDigest instance.
func NewTimeWindowQuantile ¶
func NewTimeWindowQuantile(compression float64, paneCount int, timeWindowSeconds int64) *TimeWindowQuantile
func (*TimeWindowQuantile) Add ¶
func (t *TimeWindowQuantile) Add(value float64)
Add adds a value to the sliding window's current pane.
func (*TimeWindowQuantile) Quantile ¶
func (t *TimeWindowQuantile) Quantile(q float64) float64
Quantile returns a quantile of the sliding window by merging all panes.
func (*TimeWindowQuantile) Quantiles ¶
func (t *TimeWindowQuantile) Quantiles(qs []float64) []float64
Quantiles returns quantiles of the sliding window by merging all panes.