Documentation ¶ Index ¶ type Pool func New[T any](limit int, ...) *Pool[T] func (p *Pool[T]) Close(ctx context.Context) (err error) func (p *Pool[T]) With(ctx context.Context, f func(ctx context.Context, item *T) error) error Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type Pool ¶ type Pool[T any] struct { // contains filtered or unexported fields } func New ¶ func New[T any]( limit int, createItem func(ctx context.Context, onClose func(item *T)) (*T, error), deleteItem func(ctx context.Context, item *T) error, checkErr func(err error) bool, opts ...option[T], ) *Pool[T] func (*Pool[T]) Close ¶ func (p *Pool[T]) Close(ctx context.Context) (err error) Close deletes all stored items inside Pool. It also stops all underlying timers and goroutines. It returns first error occurred during stale items' deletion. Note that even on error it calls Close() on each item. func (*Pool[T]) With ¶ func (p *Pool[T]) With(ctx context.Context, f func(ctx context.Context, item *T) error) error Source Files ¶ View all Source files errors.go pool.go Click to show internal directories. Click to hide internal directories.