workertracker

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry tracks active workers that are polling for tasks. It is safe for concurrent use.

func New

func New() *Registry

New creates a new worker registry.

func (*Registry) ListWorkers

func (r *Registry) ListWorkers(staleness time.Duration) []WorkerInfo

ListWorkers returns info about all workers that have polled recently. Workers that haven't polled in the given staleness duration are pruned.

func (*Registry) RecordPollEnd

func (r *Registry) RecordPollEnd(workerID string)

RecordPollEnd is called when a worker's long-poll request completes.

func (*Registry) RecordPollStart

func (r *Registry) RecordPollStart(workerID string, maxConcurrent, activeTasks int)

RecordPollStart is called when a worker begins a long-poll request.

type WorkerInfo

type WorkerInfo struct {
	// WorkerID is a unique identifier for this worker instance.
	WorkerID string `json:"worker_id"`
	// MaxConcurrentTasks is the maximum number of tasks this worker can run simultaneously.
	MaxConcurrentTasks int `json:"max_concurrent_tasks"`
	// ActiveTasks is the number of tasks currently being executed by this worker.
	ActiveTasks int `json:"active_tasks"`
	// ConnectedAt is when this worker first connected.
	ConnectedAt time.Time `json:"connected_at"`
	// LastPollAt is when this worker last polled for work.
	LastPollAt time.Time `json:"last_poll_at"`
	// UptimeMs is total uptime since the worker first connected.
	UptimeMs int64 `json:"uptime_ms"`
	// Polling indicates whether the worker is currently in a long-poll request.
	Polling bool `json:"polling"`
}

WorkerInfo represents a connected worker and its metadata.

Jump to

Keyboard shortcuts

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