update meter options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
6c68d39081
commit
a10328ce5b
@ -137,6 +137,13 @@ func WithName(n string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithMeter sets the meter
|
||||
func WithMeter(m meter.Meter) Option {
|
||||
return func(o *Options) {
|
||||
o.Meter = m
|
||||
}
|
||||
}
|
||||
|
||||
// WithTimeFunc sets the func to obtain current time
|
||||
func WithTimeFunc(fn func() time.Time) Option {
|
||||
return func(o *Options) {
|
||||
|
@ -1,6 +1,9 @@
|
||||
package pool
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Pool[T any] struct {
|
||||
p *sync.Pool
|
||||
@ -23,3 +26,11 @@ func (p Pool[T]) Get() T {
|
||||
func (p Pool[T]) Put(t T) {
|
||||
p.p.Put(t)
|
||||
}
|
||||
|
||||
func NewBytePool(size int) Pool[T] {
|
||||
return NewPool(func() []byte { return make([]byte, size) })
|
||||
}
|
||||
|
||||
func NewBytesPool() Pool[T] {
|
||||
return NewPool(func() *bytes.Buffer { return bytes.NewBuffer(nil) })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user