Documentation
¶
Overview ¶
Package pool provides gRPC connection pool client
This re-implementation maintains the public Conn interface unchanged while using atomic operations for efficient, lock-free connection management. Additional features such as DNS lookup, port scanning, and metrics collection are incorporated.
Index ¶
- func Metrics(ctx context.Context) map[string]uint64
- type ClientConn
- type Conn
- type DialOption
- type Option
- func WithAddr(addr string) Option
- func WithBackoff(bo backoff.Backoff) Option
- func WithDialOptions(opts ...DialOption) Option
- func WithDialTimeout(dur string) Option
- func WithEndPort(port int) Option
- func WithErrGroup(eg errgroup.Group) Option
- func WithHost(host string) Option
- func WithOldConnCloseDelay(dur string) Option
- func WithPort(port int) Option
- func WithResolveDNS(enable bool) Option
- func WithSize(size uint64) Option
- func WithStartPort(port int) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn interface {
// Connect establishes connections for all slots.
Connect(context.Context) (Conn, error)
// Disconnect gracefully closes all connections in the pool.
Disconnect(context.Context) error
// Do executes the provided function using a healthy connection.
Do(context.Context, func(*ClientConn) error) error
// Get returns a healthy connection from the pool, if available.
Get(context.Context) (*ClientConn, bool)
// IsHealthy checks the overall health of the pool.
IsHealthy(context.Context) bool
// IsIPConn indicates whether the pool is using direct IP connections.
IsIPConn() bool
// Len returns the number of connection slots.
Len() uint64
// Size returns the configured pool size.
Size() uint64
// Reconnect re-establishes connections if the pool is unhealthy or if forced.
Reconnect(context.Context, bool) (Conn, error)
// String returns a string representation of the pool's state.
String() string
}
Conn defines the interface for a gRPC connection pool.
type Option ¶
type Option func(*pool)
Option defines a functional option for configuring the pool.
func WithBackoff ¶
WithBackoff sets the backoff strategy.
func WithDialOptions ¶
func WithDialOptions(opts ...DialOption) Option
WithDialOptions appends gRPC dial options.
func WithDialTimeout ¶ added in v0.0.32
WithDialTimeout sets the dial timeout duration.
func WithErrGroup ¶ added in v1.3.1
WithErrGroup sets the errgroup for goroutine management.
func WithOldConnCloseDelay ¶ added in v1.7.17
WithOldConnCloseDelay sets the delay before closing old connections.
func WithResolveDNS ¶ added in v0.0.45
WithResolveDNS enables or disables DNS resolution.
func WithStartPort ¶
WithStartPort sets the starting port for scanning.