Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/queue/util.go

25 lines
548 B

package queue
import "github.com/prometheus/prometheus/util/pool"
// SlicePool uses a bucket pool and wraps the Get() and Put() functions for
// simpler access.
type SlicePool[T any] struct {
p *pool.Pool
}
func NewSlicePool[T any](minSize, maxSize int, factor float64) *SlicePool[T] {
return &SlicePool[T]{
p: pool.New(minSize, maxSize, factor, func(i int) interface{} {
return make([]T, 0, i)
}),
}
}
func (sp *SlicePool[T]) Get(n int) []T {
return sp.p.Get(n).([]T)
}
func (sp *SlicePool[T]) Put(buf []T) {
sp.p.Put(buf[0:0])
}