pool

package
v3.75.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 50

Variables

This section is empty.

Functions

func WithCloseItemTimeout added in v3.59.0

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

func WithCreateFunc added in v3.58.0

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

func WithCreateItemTimeout added in v3.59.0

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

func WithLimit added in v3.59.0

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

func WithTrace added in v3.58.0

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

Types

type ChangeInfo added in v3.59.0

type ChangeInfo = Stats

type CloseDoneInfo added in v3.58.0

type CloseDoneInfo struct {
	Error error
}

type CloseStartInfo added in v3.58.0

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 added in v3.58.0

type GetDoneInfo struct {
	Error error
}

type GetStartInfo added in v3.58.0

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 added in v3.58.0

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

type NewDoneInfo added in v3.58.0

type NewDoneInfo struct {
	Limit int
}

type NewStartInfo added in v3.58.0

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
}

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 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 PutDoneInfo added in v3.58.0

type PutDoneInfo struct {
	Error error
}

type PutStartInfo added in v3.58.0

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 Stats added in v3.75.1

type Stats struct {
	Limit int
	Index int
	Idle  int
	InUse int
}

type Trace added in v3.58.0

type Trace struct {
	OnNew    func(*NewStartInfo) func(*NewDoneInfo)
	OnClose  func(*CloseStartInfo) func(*CloseDoneInfo)
	OnTry    func(*TryStartInfo) func(*TryDoneInfo)
	OnWith   func(*WithStartInfo) func(*WithDoneInfo)
	OnPut    func(*PutStartInfo) func(*PutDoneInfo)
	OnGet    func(*GetStartInfo) func(*GetDoneInfo)
	OnChange func(ChangeInfo)
}

type TryDoneInfo added in v3.58.0

type TryDoneInfo struct {
	Error error
}

type TryStartInfo added in v3.58.0

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 WithDoneInfo added in v3.58.0

type WithDoneInfo struct {
	Error error

	Attempts int
}

type WithStartInfo added in v3.58.0

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
}

Jump to

Keyboard shortcuts

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