Versions in this module Expand all Collapse all v1 v1.0.1 Sep 22, 2023 v1.0.0 Jul 26, 2023 Changes in this version + const DefaultMaxGoroutineIdleDuration + const DefaultMaxGoroutinesAmount + var ErrExpired = errors.New("resPool: getting expired resource") + var ErrLack = errors.New("lack of goroutines, because exceeded maxGoroutinesAmount limit.") + var ErrWorkshopClosed = fmt.Errorf("%s", "workshop is closed") + type Avatar struct + func (avatar *Avatar) Free(err error) + func (avatar *Avatar) ResPool() ResPool + type GoPool struct + func NewGoPool(maxGoroutinesAmount int, maxGoroutineIdleDuration time.Duration) *GoPool + func (gp *GoPool) Go(fn func()) error + func (gp *GoPool) Stop() + func (gp *GoPool) TryGo(fn func()) + type ResPool interface + Callback func(func(Resource) error) error + CallbackContext func(context.Context, func(Resource) error) error + Close func() error + Get func() (Resource, error) + GetContext func(context.Context) (Resource, error) + Name func() string + Put func(Resource, error) + SetMaxIdle func(n int) + SetMaxLifetime func(d time.Duration) + SetMaxOpen func(n int) + Stats func() ResPoolStats + func NewResPool(name string, newfunc func(context.Context) (Resource, error)) ResPool + type ResPoolStats struct + ClosedResources uint64 + FreeResources int + OpenResources int + type ResPools struct + func NewResPools() *ResPools + func (c *ResPools) Clean() + func (c *ResPools) Del(name string) + func (c *ResPools) Get(name string) (ResPool, bool) + func (c *ResPools) GetAll() []ResPool + func (c *ResPools) Set(pool ResPool) + type Resource interface + Close func() error + GetAvatar func() *Avatar + SetAvatar func(*Avatar) + type Worker interface + Close func() error + Health func() bool + type Workshop struct + func NewWorkshop(maxQuota int, maxIdleDuration time.Duration, ...) *Workshop + func (w *Workshop) Callback(fn func(Worker) error) (err error) + func (w *Workshop) Close() + func (w *Workshop) Fire(worker Worker) + func (w *Workshop) Hire() (Worker, error) + func (w *Workshop) Stats() WorkshopStats + type WorkshopStats struct + Created uint64 + Doing int32 + Done uint64 + Idle int32 + MaxLoad int32 + MinLoad int32 + Worker int32