Package pool

import "github.com/gonitro/nitro/util/pool"

Overview ▾

Package pool is a connection pool

type Conn

type Conn interface {
    // unique id of connection
    Id() string
    // time it was created
    Created() time.Time
    // embedded connection

type Option

type Option func(*Options)

func Size

func Size(i int) Option

func TTL

func TTL(t time.Duration) Option

func Transport

func Transport(t network.Transport) Option

type Options

type Options struct {
    Transport network.Transport
    TTL       time.Duration
    Size      int

type Pool

Pool is an interface for connection pooling

type Pool interface {
    // Close the pool
    Close() error
    // Get a connection
    Get(addr string, opts ...network.DialOption) (Conn, error)
    // Release the connection
    Release(c Conn, status error) error

func NewPool

func NewPool(opts ...Option) Pool