utils

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionPool

type ConnectionPool struct {
	// contains filtered or unexported fields
}

ConnectionPool implements a generic connection pool

func NewConnectionPool

func NewConnectionPool(opts PoolOptions) *ConnectionPool

NewConnectionPool creates a new connection pool

func (*ConnectionPool) Close

func (p *ConnectionPool) Close() error

Close closes all connections in the pool

func (*ConnectionPool) Get

func (p *ConnectionPool) Get(ctx context.Context) (interface{}, error)

Get retrieves a connection from the pool

func (*ConnectionPool) Put

func (p *ConnectionPool) Put(conn interface{})

Put returns a connection to the pool

type Pool

type Pool interface {
	// Get retrieves a connection from the pool
	Get(ctx context.Context) (interface{}, error)
	// Put returns a connection to the pool
	Put(conn interface{})
	// Close closes all connections in the pool
	Close() error
}

Pool defines the interface for connection pooling

type PoolOptions

type PoolOptions struct {
	CreateConn   func() (interface{}, error)
	ValidateConn func(interface{}) bool
	CloseConn    func(interface{}) error
	MaxIdle      int
	MaxActive    int
	IdleTimeout  time.Duration
}

PoolOptions configures the connection pool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL