package pool

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

Index

Constants

const (
	DefaultLimit = 50
)

Functions

func WithClock

func WithClock[PT Item[T], T any](clock clockwork.Clock) option[PT, T]

func WithCloseItemTimeout

func WithCloseItemTimeout[PT Item[T], T any](t time.Duration) option[PT, T]

func WithCreateItemFunc

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

func WithCreateItemTimeout

func WithCreateItemTimeout[PT Item[T], T any](t time.Duration) option[PT, T]

func WithIdleThreshold

func WithIdleThreshold[PT Item[T], T any](idleThreshold time.Duration) option[PT, T]

func WithLimit

func WithLimit[PT Item[T], T any](size int) option[PT, T]

func WithTrace

func WithTrace[PT Item[T], T any](t *Trace) option[PT, T]

Types

type Config

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

type Item

type Item[T any] interface {
	*T
	IsAlive() bool
	Close(ctx context.Context) error
}

type Pool

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

func New

func New[PT Item[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.79.2
Published
Sep 6, 2024
Platform
linux/amd64
Imports
14 packages
Last checked
22 seconds ago

Tools for package owners.