jobworker

package
v0.0.0-...-7914164 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package jobworker implements the job execution engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrJobPanic is returned when a job panics during execution.
	ErrJobPanic = errors.New("job panicked during execution")

	// ErrUnknownJobType is returned when a job type is not registered in the registry.
	ErrUnknownJobType = errors.New("unknown job type")
)

Functions

This section is empty.

Types

type JobWorker

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

JobWorker executes jobs from the queue.

func NewJobWorker

func NewJobWorker(
	database *bun.DB,
	dbService db.Service,
	cfg *config.Config,
	svc *services.Registry,
	jobSvc jobsvc.Service,
) *JobWorker

NewJobWorker creates a new job worker.

func (*JobWorker) Run

func (w *JobWorker) Run(ctx context.Context) error

Run starts the worker with multiple internal runners (blocking).

func (*JobWorker) SetFaultLatch

func (w *JobWorker) SetFaultLatch(latch *dbfault.Latch)

SetFaultLatch installs the process-wide structural-fault latch. Set by the server before Run; a worker without one never terminates the process.

type QueueDepthSampler

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

QueueDepthSampler periodically samples the background-job queue depth and publishes it to the solidping_jobs_queue_depth gauge. It runs one cheap COUNT(*) ... GROUP BY status query per tick and zero-fills absent statuses so a drained status drops to 0 rather than going stale.

func NewQueueDepthSampler

func NewQueueDepthSampler(jobSvc jobsvc.Service) *QueueDepthSampler

NewQueueDepthSampler creates a queue-depth sampler with the default interval.

func (*QueueDepthSampler) Run

func (s *QueueDepthSampler) Run(ctx context.Context) error

Run samples once immediately, then on every tick until ctx is canceled. It always returns ctx.Err() so callers can ignore context.Canceled.

Jump to

Keyboard shortcuts

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