pool

package
v3.57.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

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

Jump to

Keyboard shortcuts

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