competition

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: 5 Imported by: 0

README

api/routes/competition

HTTP handlers for operator control over the running competition. These routes are the interface an organizer uses to halt and resume the competition mid-event, and to inspect its current state. They are not consumed by agents.

The package distinguishes two independent kinds of pause. A scoring pause leaves agents working — checks still run and the scoreboard still reflects the most recent result for every service — but results stop contributing to team pass and total counters, so no team loses uptime for the duration. A check pause goes further and stops the work itself: agents are handed a no-op instead of a real assignment and idle until the pause lifts. Each kind is held and toggled separately, so an operator can stop scoring without stopping the checks, or stop both.

Toggling is handled by a single parameterized handler shared across all four pause and unpause routes, with the desired state and pause kind bound at registration time rather than read from the request, so there is no request body to validate and no way for a caller to name a state the router does not already expose. A toggle that would be a no-op is reported rather than silently accepted: requesting a state the competition is already in aborts with 418 I'm a Teapot and leaves the stored state untouched. A real change returns 200 with a confirmation, and a database failure returns 500.

A separate read-only handler reports the full picture in one response — both pause kinds and, for each, the moment it entered its current state. Because all pause state is stored in the database rather than held in memory, every handler in this package requires the database sink and is replaced at startup with a 501 Not Implemented handler when none is configured.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePauseState

func ChangePauseState(desiredState types.PauseState, pauseType types.PauseType) func(c *gin.Context)

ChangePauseState builds a handler that moves one pause kind into one state. The state and pause kind are bound at route registration time, so each of the four pause/unpause paths is this same handler with different arguments.

@Summary		Pause or unpause the competition
@Description	Moves one of the two independent pauses into the requested state. A scoring pause leaves checks running but stops results counting toward team totals; a check pause stops checks being handed to agents entirely. The target state and pause kind are fixed by the path, so there is no request body. Requesting a state the competition is already in changes nothing and returns 418.
@Tags			comp
@Produce		json
@Success		200	{object}	object
@Failure		418	{object}	object
@Failure		500	{object}	object
@Failure		501	{object}	object
@Router			/comp/pause-checks [post]
@Router			/comp/unpause-checks [post]
@Router			/comp/pause-scoring [post]
@Router			/comp/unpause-scoring [post]

func PauseStatus

func PauseStatus(c *gin.Context)

PauseStatus reports the current state of both competition pauses.

@Summary		Get competition pause status
@Description	Reports both pause kinds at once — whether scoring is paused and whether checks are paused — each with the moment it entered its current state.
@Tags			comp
@Produce		json
@Success		200	{object}	types.PauseRecord
@Failure		500	{object}	object
@Failure		501	{object}	object
@Router			/comp/pause-status [get]

Types

This section is empty.

Jump to

Keyboard shortcuts

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