Documentation ¶
Index ¶
Constants ¶
View Source
const ( // CheckIdleInterval the interval of check and process idle eni CheckIdleInterval = 2 * time.Minute )
Variables ¶
View Source
var ( ErrNoAvailableResource = errors.New("no available resource") ErrInvalidState = errors.New("invalid state") ErrNotFound = errors.New("not found") ErrContextDone = errors.New("context done") ErrInvalidArguments = errors.New("invalid arguments") )
Errors of pool
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v1.1.0
type Config struct { Name string Type string Factory ObjectFactory Initializer Initializer MinIdle int MaxIdle int Capacity int }
Config configuration of pool
type ObjectFactory ¶
type ObjectFactory interface { // Create res with count Create(count int) ([]types.NetworkResource, error) Dispose(types.NetworkResource) error ListResource() (map[string]types.NetworkResource, error) Check(types.NetworkResource) error // Reconcile run periodicity Reconcile() }
ObjectFactory interface of network resource object factory
type ObjectPool ¶
type ObjectPool interface { Acquire(ctx context.Context, resID, idempotentKey string) (types.NetworkResource, error) ReleaseWithReservation(resID string, reservation time.Duration) error Release(resID string) error AcquireAny(ctx context.Context, idempotentKey string) (types.NetworkResource, error) Stat(resID string) (types.NetworkResource, error) GetName() string tracing.ResourceMappingHandler }
ObjectPool object pool interface
func NewSimpleObjectPool ¶
func NewSimpleObjectPool(cfg Config) (ObjectPool, error)
NewSimpleObjectPool return an object pool implement
type ResourceHolder ¶
type ResourceHolder interface { AddIdle(resource types.NetworkResource) AddInvalid(resource types.NetworkResource) AddInuse(resource types.NetworkResource, idempotentKey string) }
ResourceHolder interface to initialize pool
Click to show internal directories.
Click to hide internal directories.