Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Subscriber ¶
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is used to handle work of the WorkerPool.
func NewWorker ¶
func NewWorker(id int, channelBufferSize int, pool *WorkerPool) Worker
NewWorker creates a new Worker.
func (*Worker) EnqueueEvent ¶
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool is used to divide [Subscriber]s between [Worker]s. This prevents one Worker of being very busy.
func NewWorkerPool ¶
func NewWorkerPool( logger *slog.Logger, maxWorkers int, channelBufferSize int, ) *WorkerPool
NewWorkerPool creates a new WorkerPool.
func (*WorkerPool) Active ¶
func (pool *WorkerPool) Active() bool
Active checks if the WorkerPool is active by checking if any Worker is active.
func (*WorkerPool) AddSubscriber ¶
func (pool *WorkerPool) AddSubscriber(sub Subscriber)
AddSubscriber adds a Subscriber to the WorkerPool.
func (*WorkerPool) EnqueueEvent ¶
func (pool *WorkerPool) EnqueueEvent(event any)
EnqueueEvent puts an event on the Worker channels.
func (*WorkerPool) RemoveSubscriber ¶
func (pool *WorkerPool) RemoveSubscriber(sub Subscriber)
RemoveSubscriber removes a Subscriber from the WorkerPool.
func (*WorkerPool) Start ¶
func (pool *WorkerPool) Start()
Start starts [Worker]s of a WorkerPool if they weren't active yet.
Click to show internal directories.
Click to hide internal directories.