Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCleanupPeriod ¶
WithCleanupPeriod option sets the cleanup period for the worker pool
func WithIdleTimeout ¶
WithIdleTimeout option sets the idle timeout for the worker pool
Types ¶
type Worker ¶
type Worker interface { // Work triggers the worker to work and returns true if it did work, false otherwise. // The worker's idle time is calculated based on the return value of this method Work() bool // SleepDurations returns the sleep durations for the worker (min, max), i.e. how long the worker should sleep if it has no work to do SleepDurations() (min, max time.Duration) // Stop stops the worker and waits until all its goroutines have stopped Stop() }
Worker is a worker that can be pinged for work and stopped by the worker pool when it is idle
type WorkerPool ¶
type WorkerPool interface { // PingWorker instructs the pool to ping the worker for the given partition PingWorker(partition string) // Shutdown stops all workers in the pool and waits for them to stop Shutdown() // Size returns the number of workers in the pool Size() int }
WorkerPool manages a pool of workers and their lifecycle
func New ¶
func New(ctx context.Context, workerSupplier WorkerSupplier, logger logger.Logger, opts ...func(*workerPool)) WorkerPool
New creates a new worker pool
type WorkerSupplier ¶
WorkerSupplier is a function able to create a new worker for the given partition
Click to show internal directories.
Click to hide internal directories.