Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrWorkerStatus = errors.New("uninitialized worker, use pool.Hire()")
)
Functions ¶
This section is empty.
Types ¶
type DummyMetrics ¶
type DummyMetrics struct{}
DummyMetrics is a stub metrics writer handler that uses by default and does nothing. Need just to reduce checks in code.
func (DummyMetrics) Fire ¶
func (DummyMetrics) Fire()
func (DummyMetrics) Hire ¶
func (DummyMetrics) Hire(bool)
func (DummyMetrics) Retire ¶
func (DummyMetrics) Retire()
type MetricsWriter ¶
type MetricsWriter interface {
// Hire registers taking worker from the pool.
Hire(unknown bool)
// Fire registers returning worker to the pool.
Fire()
// Retire registers worker leak (with release).
Retire()
}
MetricsWriter is an interface of metrics handler. See example of implementations https://github.com/koykov/metrics_writers/tree/master/laborpool.
type Pool ¶
type Pool struct {
// Size indicates how many workers may be stored in the pool.
// Workers that overflows that limit will release immediately.
Size uint
// PensionFactor indicates the possibility to retire worker to the pension.
PensionFactor float32
// MetricsWriter writers pool metrics.
MetricsWriter MetricsWriter
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.