Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotTask error = errors.Base("task pool entity is not a task")
)
Functions ¶
func InitPrometheus ¶ added in v0.5.9
func InitPrometheus()
Initialise Prometheus metrics for this module.
Types ¶
type Config ¶
type Config struct {
Name string // Worker pool name for logger and metrics.
MinWorkers int64 // Minimum number of workers.
MaxWorkers int64 // Maximum number of workers.
Logger logger.Logger // Logger instance.
Parent context.Context // Parent context.
IdleTimeout time.Duration // Idle timeout duration.
}
func (*Config) SetItleTimeout ¶
Set the idle timeout value.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task structure.
type WorkerPool ¶
type WorkerPool interface {
// Start the worker pool.
Start()
// Stop the worker pool.
Stop()
// Submit a task to the worker pool.
Submit(UserData) error
// Return the number of current workers in the pool.
WorkerCount() int64
// Return the minimum number of workers in the pool.
MinWorkers() int64
// Return the maximum number of workers in the pool.
MaxWorkers() int64
// Set the minimum number of workers to the given value.
SetMinWorkers(int64)
// Set the maximum number of workers to the given value.
SetMaxWorkers(int64)
// Set the task callback function.
SetTaskFunction(TaskFn)
}
Worker pool interface.
func NewWorkerPool ¶
func NewWorkerPool(config *Config, workfn TaskFn) WorkerPool
Create a new worker pool.
Click to show internal directories.
Click to hide internal directories.