worker

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Health

type Health struct {
	Running     bool   `json:"running"`
	QueueHealth bool   `json:"queue_health"`
	Error       string `json:"error,omitempty"`
}

Health returns health status of the worker.

type Orchestrator

type Orchestrator interface {
	SyncSource(ctx context.Context, sourceID string) (*domain.SyncResult, error)
	SyncAll(ctx context.Context) ([]*domain.SyncResult, error)
}

Orchestrator defines the sync operations needed by the worker. This is a minimal interface to allow for testing.

type Worker

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

Worker processes tasks from the task queue. It runs the sync orchestrator for each sync task.

func NewWorker

func NewWorker(cfg WorkerConfig) *Worker

NewWorker creates a new task worker.

func (*Worker) Health

func (w *Worker) Health(ctx context.Context) Health

Health returns the health status of the worker.

func (*Worker) Start

func (w *Worker) Start(ctx context.Context) error

Start begins the worker loop. It runs until Stop is called or context is cancelled.

func (*Worker) Stop

func (w *Worker) Stop()

Stop gracefully stops the worker.

func (*Worker) Wait

func (w *Worker) Wait()

Wait blocks until the worker stops.

type WorkerConfig

type WorkerConfig struct {
	TaskQueue      driven.TaskQueue
	Orchestrator   Orchestrator
	Scheduler      *services.Scheduler
	Logger         *slog.Logger
	Concurrency    int // Number of concurrent task processors
	DequeueTimeout int // Seconds to wait for a task before checking again
}

WorkerConfig holds configuration for the worker.

Jump to

Keyboard shortcuts

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