update meter options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
6c68d39081
commit
1a9236caad
@ -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
|
// WithTimeFunc sets the func to obtain current time
|
||||||
func WithTimeFunc(fn func() time.Time) Option {
|
func WithTimeFunc(fn func() time.Time) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package pool
|
package pool
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
|
"bytes"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
type Pool[T any] struct {
|
type Pool[T any] struct {
|
||||||
p *sync.Pool
|
p *sync.Pool
|
||||||
@ -23,3 +26,11 @@ func (p Pool[T]) Get() T {
|
|||||||
func (p Pool[T]) Put(t T) {
|
func (p Pool[T]) Put(t T) {
|
||||||
p.p.Put(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…
x
Reference in New Issue
Block a user