pool

package
v3.81.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLimit = 50
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v3.77.0

type Config[PT ItemConstraint[T], T any] struct {
	// contains filtered or unexported fields
}

type Item added in v3.58.0

type Item interface {
	IsAlive() bool
	Close(ctx context.Context) error
}

type ItemConstraint added in v3.80.3

type ItemConstraint[T any] interface {
	*T
	Item
}

type Option added in v3.80.3

type Option[PT ItemConstraint[T], T any] func(c *Config[PT, T])

func WithClock added in v3.79.1

func WithClock[PT ItemConstraint[T], T any](clock clockwork.Clock) Option[PT, T]

func WithCloseItemTimeout added in v3.59.0

func WithCloseItemTimeout[PT ItemConstraint[T], T any](t time.Duration) Option[PT, T]

func WithCreateItemFunc added in v3.79.1

func WithCreateItemFunc[PT ItemConstraint[T], T any](f func(ctx context.Context) (PT, error)) Option[PT, T]

func WithCreateItemTimeout added in v3.59.0

func WithCreateItemTimeout[PT ItemConstraint[T], T any](t time.Duration) Option[PT, T]

func WithIdleTimeToLive added in v3.80.3

func WithIdleTimeToLive[PT ItemConstraint[T], T any](idleTTL time.Duration) Option[PT, T]

func WithItemUsageLimit added in v3.80.10

func WithItemUsageLimit[PT ItemConstraint[T], T any](itemUsageLimit uint64) Option[PT, T]

func WithLimit added in v3.59.0

func WithLimit[PT ItemConstraint[T], T any](size int) Option[PT, T]

func WithSyncCloseItem added in v3.80.0

func WithSyncCloseItem[PT ItemConstraint[T], T any]() Option[PT, T]

func WithTrace added in v3.58.0

func WithTrace[PT ItemConstraint[T], T any](t *Trace) Option[PT, T]

type Pool

type Pool[PT ItemConstraint[T], T any] struct {
	// contains filtered or unexported fields
}

func New

func New[PT ItemConstraint[T], T any](
	ctx context.Context,
	opts ...Option[PT, T],
) *Pool[PT, T]

func (*Pool[PT, T]) Close

func (p *Pool[PT, T]) Close(ctx context.Context) (finalErr error)

func (*Pool[PT, T]) Stats added in v3.59.0

func (p *Pool[PT, T]) Stats() Stats

func (*Pool[PT, T]) With

func (p *Pool[PT, T]) With(
	ctx context.Context,
	f func(ctx context.Context, item PT) error,
	opts ...retry.Option,
) (finalErr error)

type Stats added in v3.75.1

type Stats struct {
	Limit            int
	Index            int
	Idle             int
	Wait             int
	CreateInProgress int
}

type Trace added in v3.58.0

type Trace struct {
	OnNew   func(ctx *context.Context, call stack.Caller) func(limit int)
	OnClose func(ctx *context.Context, call stack.Caller) func(err error)
	OnTry   func(ctx *context.Context, call stack.Caller) func(err error)
	OnWith  func(ctx *context.Context, call stack.Caller) func(attempts int, err error)
	OnPut   func(ctx *context.Context, call stack.Caller, item any) func(err error)
	OnGet   func(ctx *context.Context, call stack.Caller) func(item any, attempts int, err error)

	OnChange func(Stats)
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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