pool

package
v0.0.0-...-2d91a95 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pool is a package ... General resource pool, dynamically increase the resource instance, and support the idle resource timing recovery function.

Index

Constants

View Source
const (
	// gcTime is a constanta ...
	GcTime = 60e9
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func() (Src, error)

factory is interface ... Create a resource method

type Pool

type Pool interface {
	// call the resource in the resource pool
	Call(func(Src) error) error
	// Destroy resource pool
	Close()
	// returns the current number of resources
	Len() int
}

Pool is interface ... resource pool (maximum capacity should be set)

func ClassicPool

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

classicPool is a function ... build a classic resource pool

type Src

type Src interface {
	// determine whether the resource is available
	Usable() bool
	// After using the reset method
	Reset()
	// By the resource pool before the self-destruction method
	Close()
}

Src is interface resource interface

Jump to

Keyboard shortcuts

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