agent

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

README

api/sinks/postgres/agent

Database functions used exclusively by the agent-facing API routes. Two operations are covered: submitting a completed check result, and pulling a random credential for a given team and userlist.

Score submission is the most critical write path in the system. It runs as a single transaction across three tables: the full historical scores table (append-only), the recent scores table (one row per team/box/service combination, upserted to always reflect the latest result), and the final scores table (a running counter of total and passed checks per team/box/service, incremented in place). All three writes succeed or none do.

Credential lookup selects a random row from the scoring users table for the requested team and userlist. No validation is performed on the input; callers are expected to have already confirmed the userlist exists before calling.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddScore

func AddScore(ctx context.Context, db *pgxpool.Pool, score types.Score) error

AddScore inserts a score into the main score database. It also updates the entry for this specific box/service/team combo in the recent scores table.

func GetRandomUser

func GetRandomUser(
	ctx context.Context,
	db *pgxpool.Pool,
	userListID types.UserListName,
	teamNum types.TeamNum,
) (types.User, error)

GetRandomUser pulls a random user from a specific userlist for a specific team. This performs no validation. Will fail with an error if invalid input is given.

Types

This section is empty.

Jump to

Keyboard shortcuts

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