Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrStopTimeout = errors.New("stop timeout") ErrWorkerPoolStopped = errors.New("worker pool has stopped") )
Functions ¶
func WithChannelsBufferSize ¶
func WithChannelsBufferSize(channelsBufferSize uint) stickyWorkerPoolOption
Set ChannelsBufferSize of the worker pool config
func WithConcurrency ¶
func WithConcurrency(concurrency uint) stickyWorkerPoolOption
Set Concurrency of the worker pool config
func WithStopTimeout ¶
Set Stop timeout of the worker pool config
Types ¶
type StickyWorkerPool ¶
type StickyWorkerPool struct {
// contains filtered or unexported fields
}
This worker pool uses a hash function to stick keys with workers in order to provide a first-in-first-out behaviour among the workloads with the same key. There is no guarantee of ordering between diferent keys.
func NewStickyWorkerPool ¶
func NewStickyWorkerPool(workFn WorkFn, options ...stickyWorkerPoolOption) *StickyWorkerPool
Creates a new StickyWorkerPool
func (*StickyWorkerPool) Start ¶
func (s *StickyWorkerPool) Start(ctx context.Context)
Start starts the workers of the pool It creates starts <concurrency> go routines a.k.a. workers
func (*StickyWorkerPool) Stop ¶
func (s *StickyWorkerPool) Stop() error
Stop stops the worker It prevents worker to receive new workloads returning error and await for the workloads flush or timeout
Click to show internal directories.
Click to hide internal directories.