github.com/micro/go-micro/v2@v2.9.1/util/pool/pool.go (about) 1 // Package pool is a connection pool 2 package pool 3 4 import ( 5 "time" 6 7 "github.com/micro/go-micro/v2/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 // unique id of connection 22 Id() string 23 // time it was created 24 Created() time.Time 25 // embedded connection 26 transport.Client 27 } 28 29 func NewPool(opts ...Option) Pool { 30 var options Options 31 for _, o := range opts { 32 o(&options) 33 } 34 return newPool(options) 35 }