Versions in this module Expand all Collapse all v0 v0.1.0 Oct 15, 2025 Changes in this version + var ErrCapacityExceeded = errors.New("capacity exceeded maximum limit") + var ErrClosed = errors.New("pool is closed") + var ErrInvalidCapacity = errors.New("capacity must be positive") + var ErrInvalidConfiguration = errors.New("invalid pool configuration") + var ErrMissingConstructor = errors.New("constructor function is required") + var ErrPoolExhausted = errors.New("pool exhausted: no items available") + var ErrTimeout = errors.New("timeout waiting for item") + var ErrValidationFailed = errors.New("item validation failed") + type Config struct + CustomGrowthFunc func(currentCapacity int) int + Destructor func(T) + EagerWarmup bool + GrowthStrategy GrowthStrategy + HealthCheck func(T) bool + IdleTimeout time.Duration + InitialCapacity int + LinearGrowthStep int + MaxCapacity int + Metrics bool + New func() T + Reset func(T) + ShardCount int + Validate func(T) bool + func DefaultConfig[T any](constructor func() T) Config[T] + func (c *Config[T]) ValidateConfig() error + type FixedPool struct + func NewFixedPool[T any](cfg Config[T]) (*FixedPool[T], error) + func (p *FixedPool[T]) Close() error + func (p *FixedPool[T]) Get() T + func (p *FixedPool[T]) GetBlocking(ctx context.Context) (T, error) + func (p *FixedPool[T]) GetWithError() (T, error) + func (p *FixedPool[T]) Put(item T) + func (p *FixedPool[T]) Stats() PoolStats + type GenericPool struct + func NewPool[T any](cfg Config[T]) (*GenericPool[T], error) + func (p *GenericPool[T]) Close() error + func (p *GenericPool[T]) Get() T + func (p *GenericPool[T]) Put(item T) + func (p *GenericPool[T]) Stats() PoolStats + type GrowingPool struct + func NewGrowingPool[T any](cfg Config[T]) (*GrowingPool[T], error) + func (p *GrowingPool[T]) Close() error + func (p *GrowingPool[T]) Get() T + func (p *GrowingPool[T]) Put(item T) + func (p *GrowingPool[T]) Stats() PoolStats + type GrowthStrategy int + const GrowthCustom + const GrowthDouble + const GrowthLinear + const GrowthNone + type Option func(*Config[T]) + func WithDestructor[T any](destructor func(T)) Option[T] + func WithEagerWarmup[T any]() Option[T] + func WithGrowthStrategy[T any](strategy GrowthStrategy) Option[T] + func WithHealthCheck[T any](healthCheck func(T) bool) Option[T] + func WithIdleTimeout[T any](timeout time.Duration) Option[T] + func WithInitialCapacity[T any](capacity int) Option[T] + func WithMaxCapacity[T any](capacity int) Option[T] + func WithMetrics[T any](enabled bool) Option[T] + func WithReset[T any](reset func(T)) Option[T] + func WithValidate[T any](validate func(T) bool) Option[T] + type Pool interface + Close func() error + Get func() T + Put func(item T) + Stats func() PoolStats + func NewPoolWithOptions[T any](constructor func() T, opts ...Option[T]) (Pool[T], error) + type PoolBuilder struct + func NewPoolBuilder[T any]() *PoolBuilder[T] + func (pb *PoolBuilder[T]) Build() (Pool[T], error) + func (pb *PoolBuilder[T]) BuildFixed() (Pool[T], error) + func (pb *PoolBuilder[T]) BuildGrowing() (Pool[T], error) + func (pb *PoolBuilder[T]) BuildSharded() (Pool[T], error) + func (pb *PoolBuilder[T]) WithConstructor(constructor func() T) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithCustomGrowth(growthFunc func(int) int) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithDestructor(destructor func(T)) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithEagerWarmup(eager bool) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithGrowthStrategy(strategy GrowthStrategy) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithHealthCheck(healthCheck func(T) bool) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithIdleTimeout(timeout time.Duration) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithInitialCapacity(capacity int) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithLinearGrowthStep(step int) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithMaxCapacity(capacity int) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithMetrics(enabled bool) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithReset(reset func(T)) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithShardCount(count int) *PoolBuilder[T] + func (pb *PoolBuilder[T]) WithValidate(validate func(T) bool) *PoolBuilder[T] + type PoolStats struct + Allocated int64 + Capacity int + Gets int64 + Grows int64 + HitRate float64 + InUse int + LastGC time.Time + Misses int64 + Puts int64 + Recycled int64 + Shards int + Shrinks int64 + Uptime time.Duration + Waiters int + func (ps *PoolStats) AllocationSavings() float64 + func (ps *PoolStats) Available() int + func (ps *PoolStats) IsHealthy(threshold float64) bool + func (ps *PoolStats) TotalOperations() int64 + func (ps *PoolStats) Utilization() float64 + type ShardConfig struct + BaseConfig Config[T] + ShardCount int + type ShardedPool struct + func NewShardedPool[T any](cfg ShardConfig[T]) (*ShardedPool[T], error) + func (sp *ShardedPool[T]) Close() error + func (sp *ShardedPool[T]) Get() T + func (sp *ShardedPool[T]) Put(item T) + func (sp *ShardedPool[T]) Stats() PoolStats + type SyncConfig struct + MaxCapacity int + Metrics bool + New func() T + Reset func(T) + type SyncPool struct + func NewSyncPool[T any](cfg SyncConfig[T]) (*SyncPool[T], error) + func (sp *SyncPool[T]) Close() error + func (sp *SyncPool[T]) Get() T + func (sp *SyncPool[T]) Put(item T) + func (sp *SyncPool[T]) Stats() PoolStats