pool

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load added in v0.10.0

func Load[T any](ctx context.Context, p Pool[T], i int) error

func With

func With[T any](ctx context.Context, pool Pool[T], fn func(T) error) error

func WithValue

func WithValue[T any, V any](ctx context.Context, pool Pool[T], fn func(T) (V, error)) (V, error)

func WithValue2

func WithValue2[T any, V any, V2 any](ctx context.Context, pool Pool[T], fn func(T) (V, V2, error)) (V, V2, error)

Types

type CloseContext

type CloseContext interface {
	Close(context.Context)
}

type CloseContextErr

type CloseContextErr interface {
	Close(context.Context) error
}

type CloseErr

type CloseErr interface {
	Close() error
}

type Closer

type Closer interface {
	Close()
}

type Config

type Config struct {
	MaxSize int64
	Preload int64
}

type Pool

type Pool[T any] interface {
	Get(context.Context) (T, error)

	Put(T) error

	Close(context.Context) error

	Len() int
}

func New

func New[T any](c Config, fn func(context.Context) (T, error)) Pool[T]

Jump to

Keyboard shortcuts

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