services

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 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.

The package also owns the global competition pause state, exposing setters and a reader over an atomic boolean. While paused, the queue is not advanced at all: every request for the next check returns a check marked as a no-op instead, which agents recognize and skip without running anything or reporting a result. Unpausing resumes handing out real checks from wherever the counter left off, so a pause costs no queue position and produces no failed checks for the duration.

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.

func IsPaused

func IsPaused() bool

func Pause

func Pause()

func Unpause

func Unpause()

Types

This section is empty.

Jump to

Keyboard shortcuts

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