worker

package
v0.0.0-...-0089d1b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TaskHandler

type TaskHandler func(ctx context.Context, task *models.TaskInfo, queue *queue.Queue) error

type TaskWorkerPool

type TaskWorkerPool interface {
	// StartWorkerPool starts background processes and workers
	// Should be run as a go routine.
	StartWorkerPool(ctx context.Context)
	// StartWorkers Starts workers up to number numWorkers defined in config.
	StartWorkers(ctx context.Context)
	// Stop Gracefully stops all workers
	Stop()
	// HeartbeatListener requeues tasks of workers whose heartbeats do not refresh within heartbeat duration
	HeartbeatListener(ctx context.Context)
	// ListenForCancelledTasks listens for task cancellation notifications
	ListenForCancelledTasks(ctx context.Context)
	// RequeueFailedTasks requeues failed tasks at regular intervals
	RequeueFailedTasks(ctx context.Context)
	// RegisterHandler assigns a function of type TaskHandler to a typename.
	// This function is the action performed to tasks of typename taskType.
	RegisterHandler(taskType string, handler TaskHandler)
}

func NewTaskWorkerPool

func NewTaskWorkerPool(queue queue.Queue, metrics *m.Metrics) TaskWorkerPool

type WorkerPool

type WorkerPool struct {
	// contains filtered or unexported fields
}

func (*WorkerPool) HeartbeatListener

func (w *WorkerPool) HeartbeatListener(ctx context.Context)

func (*WorkerPool) ListenForCancelledTasks

func (w *WorkerPool) ListenForCancelledTasks(ctx context.Context)

func (*WorkerPool) RegisterHandler

func (w *WorkerPool) RegisterHandler(taskType string, handler TaskHandler)

func (*WorkerPool) RequeueFailedTasks

func (w *WorkerPool) RequeueFailedTasks(ctx context.Context)

func (*WorkerPool) StartWorkerPool

func (w *WorkerPool) StartWorkerPool(ctx context.Context)

func (*WorkerPool) StartWorkers

func (w *WorkerPool) StartWorkers(ctx context.Context)

func (*WorkerPool) Stop

func (w *WorkerPool) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL