Documentation ¶
Index ¶
- Constants
- Variables
- func WithAutoClearInterval(autoClearInterval time.Duration) option
- func WithCap(cap int) option
- func WithCloseMethod(closeMethod func(connect any)) option
- func WithDealPanicMethod(dealPanicMethod func(panicInfo any)) option
- func WithMaxFreeTime(maxFreeTime time.Duration) option
- type ConnectPool
Constants ¶
View Source
const ( DefaultMaxFreeTime = 3 * time.Second // Default maximum idle wait time DefaultAutoCleanInterval = 2 * time.Second // Default auto-clean cycle execution DefaultCap = 1000 // Default pool cap )
Variables ¶
View Source
var DefaultDealPanicMethod = func(panicInfo any) { log.Println(panicInfo) }
Functions ¶
func WithAutoClearInterval ¶ added in v1.0.3
func WithCloseMethod ¶ added in v1.0.3
func WithCloseMethod(closeMethod func(connect any)) option
func WithDealPanicMethod ¶ added in v1.0.3
func WithDealPanicMethod(dealPanicMethod func(panicInfo any)) option
func WithMaxFreeTime ¶ added in v1.0.3
Types ¶
type ConnectPool ¶
type ConnectPool interface { Register() (newConnect any, cancelFunc func()) // Registers a connection RegisterWithTimeLimit(deadLine time.Duration) (newConnect any, cancelFunc func()) // Registers a connection with a deadline WorkingNumber() int // Gets the number of active connections Size() int // Gets the pool's cap Cap() int // Gets the pool's maximum size MaxFreeTime() time.Duration // Gets the maximum idle time for connectors AutoClearInterval() time.Duration // Gets the interval for auto-clearing Close() // Closes the pool }
func NewConnectPool ¶
func NewConnectPool(connectMethod func() any, options ...option) ConnectPool
NewConnectPool creates a new connection pool with a specified maximum size and connection creation method.
Click to show internal directories.
Click to hide internal directories.