Files
mayfly-go/server/internal/es/esm/esi/buffer_pool.go
zongyangleo 142bbd265d !134 feat: 新增支持es和连接池
* feat: 各连接,支持连接池
* feat:支持es
2025-05-21 04:42:30 +00:00

30 lines
449 B
Go

package esi
import (
"net/http/httputil"
"sync"
)
type BufferPool struct {
pool *sync.Pool
}
// 需要实现 httputil.BufferPool
var _ httputil.BufferPool = (*BufferPool)(nil)
func NewBufferPool() *BufferPool {
return &BufferPool{&sync.Pool{
New: func() interface{} {
return make([]byte, 32*1024)
},
}}
}
func (b *BufferPool) Get() []byte {
return b.pool.Get().([]byte)
}
func (b *BufferPool) Put(buf []byte) {
b.pool.Put(buf)
}