package pool

import "github.com/ydb-platform/ydb-go-sdk/v3/internal/pool"

Index

Constants

const (
	DefaultLimit = 50
)

Types

type Config

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

type Item

type Item interface {
	closer.Closer
	node.ID

	IsAlive() bool
}

type ItemConstraint

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

type Option

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

func WithClock

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

func WithCloseItemTimeout

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

func WithCreateItemFunc

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

func WithCreateItemTimeout

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

func WithIdleTimeToLive

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

func WithItemUsageLimit

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

func WithLimit

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

func WithMustDeleteItemFunc

func WithMustDeleteItemFunc[PT ItemConstraint[T], T any](f func(item PT, err error) bool) Option[PT, T]

func WithSyncCloseItem

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

func WithTrace

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

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

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

type Trace

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
}

Source Files

defaults.go errors.go pool.go stats.go trace.go

Version
v3.100.1
Published
Feb 28, 2025
Platform
js/wasm
Imports
17 packages
Last checked
1 second ago

Tools for package owners.