Versions in this module Expand all Collapse all v1 v1.0.3 Apr 18, 2025 v1.0.1 Apr 18, 2025 Changes in this version + const GrowthBlocked + const GrowthFailed + const NoItemsToMove + const NoRefillNeeded + const RefillSucceeded + const RingBufferError + var ErrAcquireLock = errors.New("unable to acquire lock") + var ErrInvalidLength = errors.New("invalid length") + var ErrIsEmpty = errors.New("ringbuffer is empty") + var ErrIsFull = errors.New("ringbuffer is full") + var ErrIsNotEmpty = errors.New("ringbuffer is not empty") + var ErrNilValue = errors.New("cannot write nil value to ring buffer") + var ErrReaderClosed = errors.New("reader closed") + var ErrTooMuchDataToWrite = errors.New("too much data to write") + var ErrWriteOnClosed = errors.New("write on closed ringbuffer") + func NewPoolConfigBuilder() *poolConfigBuilder + func ToInternalConfig(config PoolConfig) *poolConfig + type AggressivenessLevel int + const AggressivenessAggressive + const AggressivenessBalanced + const AggressivenessConservative + const AggressivenessDisabled + const AggressivenessExtreme + const AggressivenessVeryAggressive + type Example struct + Age int + Name string + type FastPathParameters interface + GetBufferSize func() int + GetFillAggressiveness func() float64 + GetGrowth func() *growthParameters + GetGrowthEventsTrigger func() int + GetRefillPercent func() float64 + GetShrink func() *shrinkParameters + GetShrinkEventsTrigger func() int + IsEnableChannelGrowth func() bool + type GrowthParameters interface + GetExponentialThresholdFactor func() float64 + GetFixedGrowthFactor func() float64 + GetGrowthPercent func() float64 + type Pool struct + func NewPool[T any](config *poolConfig, allocator func() T, cleaner func(T), poolType reflect.Type) (*Pool[T], error) + func (p *Pool[T]) Close() error + func (p *Pool[T]) Get() (zero T) + func (p *Pool[T]) IdleCheck(idles *int, shrinkPermissionIdleness *bool) + func (p *Pool[T]) IsGrowth() bool + func (p *Pool[T]) IsShrunk() bool + func (p *Pool[T]) PrintPoolStats() + func (p *Pool[T]) Put(obj T) + func (p *Pool[T]) ShrinkExecution() + func (p *Pool[T]) UtilizationCheck(underutilizationRounds *int, shrinkPermissionUtilization *bool) + type PoolConfig interface + GetFastPath func() *fastPathParameters + GetGrowth func() *growthParameters + GetHardLimit func() int + GetInitialCapacity func() int + GetRingBufferConfig func() *RingBufferConfig + GetShrink func() *shrinkParameters + IsVerbose func() bool + type RefillResult struct + GrowthBlocked bool + GrowthNeeded bool + ItemsFailed int + ItemsMoved int + Reason string + Success bool + type RingBuffer struct + func NewWithConfig[T any](size int, config *RingBufferConfig) (*RingBuffer[T], error) + func New[T any](size int) *RingBuffer[T] + func (r *RingBuffer[T]) Capacity() int + func (r *RingBuffer[T]) Close() error + func (r *RingBuffer[T]) CopyConfig(source *RingBuffer[T]) *RingBuffer[T] + func (r *RingBuffer[T]) Free() int + func (r *RingBuffer[T]) GetAll() (items []T, err error) + func (r *RingBuffer[T]) GetN(n int) (items []T, err error) + func (r *RingBuffer[T]) GetOne() (item T, err error) + func (r *RingBuffer[T]) IsEmpty() bool + func (r *RingBuffer[T]) IsFull() bool + func (r *RingBuffer[T]) Length() int + func (r *RingBuffer[T]) PeekN(n int) (items []T, err error) + func (r *RingBuffer[T]) PeekOne() (item T, err error) + func (r *RingBuffer[T]) Reset() + func (r *RingBuffer[T]) WithBlocking(block bool) *RingBuffer[T] + func (r *RingBuffer[T]) WithReadTimeout(d time.Duration) *RingBuffer[T] + func (r *RingBuffer[T]) WithTimeout(d time.Duration) *RingBuffer[T] + func (r *RingBuffer[T]) WithWriteTimeout(d time.Duration) *RingBuffer[T] + func (r *RingBuffer[T]) Write(item T) error + func (r *RingBuffer[T]) WriteMany(items []T) (n int, err error) + type RingBufferConfig struct + func (c *RingBufferConfig) GetReadTimeout() time.Duration + func (c *RingBufferConfig) GetWriteTimeout() time.Duration + func (c *RingBufferConfig) IsBlocking() bool + type RingBufferConfigBuilder struct + func NewRingBufferConfigBuilder() *RingBufferConfigBuilder + func (b *RingBufferConfigBuilder) Build(size int) (*RingBuffer[any], error) + func (b *RingBufferConfigBuilder) WithBlocking(block bool) *RingBufferConfigBuilder + func (b *RingBufferConfigBuilder) WithReadTimeout(d time.Duration) *RingBufferConfigBuilder + func (b *RingBufferConfigBuilder) WithWriteTimeout(d time.Duration) *RingBufferConfigBuilder + type RingBufferConfigInterface interface + GetCancelContext func() context.Context + GetReadTimeout func() time.Duration + GetWriteTimeout func() time.Duration + IsBlocking func() bool + type ShrinkParameters interface + GetAggressivenessLevel func() AggressivenessLevel + GetCheckInterval func() time.Duration + GetEnforceCustomConfig func() bool + GetIdleThreshold func() time.Duration + GetMaxConsecutiveShrinks func() int + GetMinCapacity func() int + GetMinIdleBeforeShrink func() int + GetMinUtilizationBeforeShrink func() float64 + GetShrinkCooldown func() time.Duration + GetShrinkPercent func() float64 + GetStableUnderutilizationRounds func() int