services

package
v0.0.55 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 8 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. It is held as an immutable snapshot — the paused flag together with the moment the competition entered that state — published behind an atomic pointer, so the read on the request path is a single atomic load with no locking and no contention between concurrent agents. Transitions swap in a freshly allocated snapshot with a compare-and-swap, retrying against the current value if another request changed the state in between, and report back whether they actually changed anything so the HTTP layer can reject a redundant pause or unpause. A separate reader returns the flag and the timestamp together as one consistent pair. The initial state comes from the config at startup, which allows a competition to boot already paused and begin scoring only once an operator says so.

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. The state is in-memory only and does not survive a restart.

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

IsPaused quickly checks if quincy is paused. True means paused, false means unpaused.

func Pause

func Pause() (changed bool)

Pause pauses quincy, updating the time it entered this state only if the state changes.

func PauseStatus added in v0.0.55

func PauseStatus() (isPaused bool, since time.Time)

PauseStatus returns the competition pause status as well as the time it entered that state.

func Unpause

func Unpause() (changed bool)

Unpause unpauses quincy, updating the stored time changed only if the state changes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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