services

package
v0.0.57 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

README

services

Generates and serves the queue of service checks consumed by agents. On startup, expands the config into a flat list of every combination of team, box, and service. The list is kept in generation order rather than shuffled, so all of a team's checks run close together in time. Agents call a single endpoint to receive the next check; the queue is served round-robin using a lock-free atomic counter so any number of concurrent agent goroutines can call the same endpoint safely without contention. When the end of the queue is reached it wraps back to the beginning. If the service has a userlist, a random credential is resolved for that team — from the database if it is configured (supporting live password changes), otherwise from the inline user list in the config file — and attached to the check before it is returned.

This package holds no pause state of its own and applies none: every call advances the queue and returns real work. Both kinds of competition pause are enforced elsewhere, by the layers on either side of this one. A scoring pause is applied where a result is recorded, so checks dispatched from here still run and still report, they simply stop counting. A check pause is applied in the route handler ahead of this package, which returns a no-op without calling in at all, leaving the queue position untouched so the paused interval consumes no checks.

Documentation

Overview

Package services contains the logic for templating and serving checks to agents. Using the specifications from the config, this package creates a queue containing all services for all boxes for all teams. This queue is then randomized, then served using a lock-free atomic counter for concurrent access. Users are randomly pulled from the database when needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNext

func GetNext(ctx context.Context, cfg *config.APIConfigSpec, db *pgxpool.Pool) (types.Service, error)

GetNext returns the next service in the queue. This is a fully templated service, with check info, team number, and a username/password.

func InitServices

func InitServices(cfg *config.APIConfigSpec) error

InitServices reads the config and generates a list containing every service for every team.

Types

This section is empty.

Jump to

Keyboard shortcuts

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