github.com/volts-dev/volts@v0.0.0-20240120094013-5e9c65924106/internal/pool/pool.go (about) 1 // Package pool is a connection pool 2 package pool 3 4 import ( 5 "time" 6 7 "github.com/volts-dev/volts/transport" 8 ) 9 10 // Pool is an interface for connection pooling 11 type Pool interface { 12 // Close the pool 13 Close() error 14 // Get a connection 15 Get(addr string, opts ...transport.DialOption) (Conn, error) 16 // Releaes the connection 17 Release(c Conn, status error) error 18 } 19 20 type Conn interface { 21 // embedded connection 22 transport.IClient 23 // unique id of connection 24 Id() string 25 // time it was created 26 Created() time.Time 27 } 28 29 func NewPool(opts ...Option) Pool { 30 var cfg Config 31 for _, o := range opts { 32 o(&cfg) 33 } 34 return newPool(cfg) 35 }