package pool

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

Index

Constants

const (
	DefaultMaxSize        = 50
	DefaultMinSize        = 0
	DefaultProducersCount = 1
)

Functions

func WithCreateFunc

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

func WithMaxSize

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

func WithMinSize

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

func WithProducersCount

func WithProducersCount[PT Item[T], T any](count int) option[PT, T]

func WithTrace

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

Types

type CloseDoneInfo

type CloseDoneInfo struct {
	Error error
}

type CloseStartInfo

type CloseStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

type GetDoneInfo

type GetDoneInfo struct {
	Error error
}

type GetStartInfo

type GetStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

type Item

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

type NewDoneInfo

type NewDoneInfo struct {
	Error error

	// actual settings
	MinSize        int
	MaxSize        int
	ProducersCount int
}

type NewStartInfo

type NewStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller

	// input settings
	MinSize        int
	MaxSize        int
	ProducersCount int
}

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],
) (p *Pool[PT, T], finalErr error)

func (*Pool[PT, T]) Close

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

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 ProduceDoneInfo

type ProduceDoneInfo struct{}

type ProduceStartInfo

type ProduceStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller

	Concurrency int
}

type PutDoneInfo

type PutDoneInfo struct {
	Error error
}

type PutStartInfo

type PutStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

type SpawnDoneInfo

type SpawnDoneInfo struct {
	Error error
}

type SpawnStartInfo

type SpawnStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

type Trace

type Trace struct {
	OnNew     func(*NewStartInfo) func(*NewDoneInfo)
	OnClose   func(*CloseStartInfo) func(*CloseDoneInfo)
	OnProduce func(*ProduceStartInfo) func(*ProduceDoneInfo)
	OnTry     func(*TryStartInfo) func(*TryDoneInfo)
	OnWith    func(*WithStartInfo) func(*WithDoneInfo)
	OnPut     func(*PutStartInfo) func(*PutDoneInfo)
	OnGet     func(*GetStartInfo) func(*GetDoneInfo)
	OnSpawn   func(*SpawnStartInfo) func(*SpawnDoneInfo)
	OnWant    func(*WantStartInfo) func(*WantDoneInfo)
}

type TryDoneInfo

type TryDoneInfo struct {
	Error error
}

type TryStartInfo

type TryStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

type WantDoneInfo

type WantDoneInfo struct {
	Error error
}

type WantStartInfo

type WantStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

type WithDoneInfo

type WithDoneInfo struct {
	Error error

	Attempts int
}

type WithStartInfo

type WithStartInfo struct {
	// Context make available context in trace stack.Callerback function.
	// Pointer to context provide replacement of context in trace stack.Callerback function.
	// Warning: concurrent access to pointer on client side must be excluded.
	// Safe replacement of context are provided only inside stack.Callerback function
	Context *context.Context
	Call    stack.Caller
}

Source Files

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

Version
v3.58.1
Published
Mar 17, 2024
Platform
linux/amd64
Imports
8 packages
Last checked
51 seconds ago

Tools for package owners.