Documentation
¶
Index ¶
- func Bucketize(value uint, buckets []uint) string
- func Filter[T any](s []T, predicate func(T) bool) iter.Seq[T]
- func JitterDuration(baseDuration, maxJitter time.Duration) time.Duration
- func LinearBuckets(minValue, maxValue float64, count int) []float64
- func Reduce[S ~[]E, E any, A any](s S, initializer A, f func(A, E) A) A
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bucketize ¶ added in v1.3.1
Bucketize will put the value of a metric into the correct bucket, and return the label for it. It is expected that the buckets are already sorted in increasing order and non-empty.
func Filter ¶ added in v1.9.0
Filter functions similar to other language list filter functions. It accepts a generic slice and a predicate function to apply to each element, returning an iterator sequence containing only the elements for which the predicate returned true.
Example filtering for even numbers:
iter := Filter([]int{1, 2, 3, 4, 5}, func(n int) bool { return n%2 == 0})
// To collect results: slices.Collect(iter) returns []int{2, 4}
func JitterDuration ¶ added in v1.9.0
func LinearBuckets ¶ added in v1.4.1
LinearBuckets returns an evenly distributed range of buckets in the closed interval [min...max]. The min and max count toward the bucket count since they are included in the range.
func Reduce ¶ added in v1.9.0
Reduce accepts a generic slice, an initializer value, and a function. It iterates over the slice applying the supplied function to the current accumulated value and each element in the slice, reducing the slice to a single value.
Example reducing to a sum:
Reduce([]int{1, 2, 3}, 0, func(accumulator int, currentValue int) int {
return accumulator + currentValue
})
returns 6.
Types ¶
This section is empty.