pool

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pool provides a generic resource pool with dynamic growth and idle resource recycling.

Index

Constants

View Source
const (
	GC_TIME = 60e9
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func() (Src, error)

Factory creates a new resource.

type Pool

type Pool interface {
	Call(func(Src) error) result.VoidResult
	Close()
	Len() int
}

Pool is a resource pool with a maximum capacity.

func ClassicPool

func ClassicPool(capacity, maxIdle int, factory Factory, gctime ...time.Duration) Pool

ClassicPool creates a classic resource pool with the given capacity and idle recycling.

type Src

type Src interface {
	Usable() bool
	Reset()
	Close()
}

Src is the resource interface.

Jump to

Keyboard shortcuts

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