MCPcopy
hub / github.com/grafana/tempo / NewPool

Function NewPool

pkg/tempopb/pool.go:32–50  ·  view source on GitHub ↗

NewPool returns a new Pool with size buckets for minSize to maxSize

(name string, minBucket, numBuckets, bktSize int)

Source from the content-addressed store, hash-verified

30
31// NewPool returns a new Pool with size buckets for minSize to maxSize
32func NewPool(name string, minBucket, numBuckets, bktSize int) *Pool {
33 if minBucket < 0 {
34 panic("invalid min bucket size")
35 }
36 if bktSize < 1 {
37 panic("invalid bucket size")
38 }
39 if numBuckets < 1 {
40 panic("invalid num buckets")
41 }
42
43 return &Pool{
44 buckets: make([]sync.Pool, numBuckets),
45 bktSize: bktSize,
46 minBucket: minBucket,
47 metricMissOver: metricAllocOutPool.WithLabelValues(name, "over"),
48 metricMissUnder: metricAllocOutPool.WithLabelValues(name, "under"),
49 }
50}
51
52// Get returns a new byte slices that fits the given size.
53func (p *Pool) Get(sz int) []byte {

Callers 5

initFunction · 0.92
initFunction · 0.70
TestPoolGetFunction · 0.70
TestBucketForFunction · 0.70

Calls

no outgoing calls

Tested by 3

TestPoolGetFunction · 0.56
TestBucketForFunction · 0.56