mirror of
https://github.com/hanzo-ds/native.git
synced 2026-10-30 20:00:34 +00:00
Module path, package names, and identifiers de-branded to native/proto/compress/ pool/tracing. Server wire-protocol strings preserved. Vendored codec surface used by hanzo-ds/go (proto + compress).
27 lines
434 B
Go
27 lines
434 B
Go
package pool
|
|
|
|
import (
|
|
"github.com/jackc/puddle/v2"
|
|
|
|
"github.com/hanzo-ds/native"
|
|
)
|
|
|
|
type connResource struct {
|
|
client *native.Client
|
|
clients []Client
|
|
}
|
|
|
|
func (cr *connResource) getConn(p *Pool, res *puddle.Resource[*connResource]) *Client {
|
|
if len(cr.clients) == 0 {
|
|
cr.clients = make([]Client, 128)
|
|
}
|
|
|
|
c := &cr.clients[len(cr.clients)-1]
|
|
cr.clients = cr.clients[0 : len(cr.clients)-1]
|
|
|
|
c.res = res
|
|
c.p = p
|
|
|
|
return c
|
|
}
|