types

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

README

types

Shared type definitions used by both the agent and the API server. Having these in a shared package with no internal dependencies allows both components to speak the same data language without either importing from the other.

Provides string-typed name aliases for the five core domain entities — teams, boxes, services, userlists, and checks — so function signatures are self-documenting and the compiler catches mismatched identifiers. Also defines the structs that flow between components: a completed score result carrying team, box, service, pass/fail status, the check's captured stdout and stderr, and a Unix microsecond timestamp; aggregated scoring statistics with pass/fail counts and a rounded uptime percentage; a service check template containing everything an agent needs to run a check except credentials (name, check name, box name, host address template, team number, and optional userlist reference); a user credential with username, password, and optional domain and NetBIOS name for Active Directory environments; and a fully rendered service check combining a template with an optional attached user. Also provides the competition pause vocabulary: a boolean-backed pause state with named constants for paused, running, and a safe default that callers ignoring an error fall back to, which is deliberately the paused value so that a dropped error stops scoring rather than silently counting; a string-typed pause kind with constants for the two independent pauses, one halting only the counting of results and one halting the checks themselves; and a record carrying both kinds at once, each paired with the moment it took effect, which is the shape returned to operators asking for current status. The rendered service check also carries a no-op marker, set when checks are paused, which tells an agent to idle rather than run anything.

Documentation

Overview

Package types contains global definitions that are shared between the agent and API. Has no dependencies and is easily importable for any Golang frontend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoxName

type BoxName string

BoxName is the unique identifier of a box.

type CheckName

type CheckName string

CheckName is the identifier of a check. This has no uniqueness constraint. It has no meaning to the API; is only used by the agent.

type PauseRecord added in v0.0.56

type PauseRecord struct {
	ScoringState PauseState `json:"scoring_is_paused"   example:"false"`
	ScoringSince time.Time  `json:"scoring_since"       example:"2026-09-25T14:02:11.482913Z"`
	CheckState   PauseState `json:"checks_are_paused"   example:"true"`
	CheckSince   time.Time  `json:"checks_since"        example:"2026-09-25T14:37:50.119204Z"`
}

PauseRecord is the state of the competitions pauses.

type PauseState added in v0.0.56

type PauseState bool

PauseState describes whether quincy should count scores during a period or not.

const (
	// Paused is the state where no scores are counted.
	Paused PauseState = true
	// Unpause is the state where scores are counted.
	Unpaused PauseState = false
	// PauseDefault can be used in error cases as a safe failure incase the caller ignores errors.
	PauseDefault PauseState = Paused
)

type PauseType added in v0.0.56

type PauseType string

Pause type defines the type of pause

const (
	// ScoringPause is a type of pause where checks are still run, but scores are not counted
	// The scoreboard reflects the most recent checks, but final scores are not updated
	ScoringPause PauseType = "scoring"

	// CheckPause is a type of pause where the scoring agents do not run checks.
	CheckPause PauseType = "check"
)

type Score

type Score struct {
	TeamNum     TeamNum     `json:"team_num"  example:"1"`
	Status      bool        `json:"status"    example:"true"`
	BoxName     BoxName     `json:"box"       example:"scrapyard"`
	ServiceName ServiceName `json:"service"   example:"blog"`
	Stdout      string      `json:"stdout"   example:"HTTP 200 OK\nexit 0"`
	Stderr      string      `json:"stderr"   example:"something got past your bow :("`

	// Timestamp is inserted by the api on submission.
	// Does not need to added when building manually.
	Timestamp int64 `json:"timestamp" example:"1700000000000000"`
}

Score is the results of a completed score check. It has a boolean pass/fail, and the stdout/stderr captured from the check.

type ScoreResult

type ScoreResult struct {
	ChecksPassed  uint64  `json:"checks_passed"  example:"42"`
	ChecksFailed  uint64  `json:"checks_failed"  example:"8"`
	TotalChecks   uint64  `json:"total_checks"   example:"50"`
	UptimePercent float64 `json:"uptime_percent" example:"84.00"`
}

ScoreResult is a flexible object used to store information about scoring results. This can be used for an entire team, one specific service for one team, one box for every team, and more.

type Service

type Service struct {
	ServiceTemplate
	User *User `json:"user,omitempty,omitzero"`
	NoOp bool  `json:"no_op,omitempty,omitzero"  example:"false"`
}

Service is a fully rendered service ready to be run by the agent. Is just a ServiceTemplate with an added user and a potential no-op order.

type ServiceName

type ServiceName string

ServiceName is the identifier of a service. This is unique under a single box, but different boxes can have services with the same ID.

type ServiceSpec

type ServiceSpec struct {
	Name      ServiceName  `yaml:"name"      mapstructure:"name"      json:"name"                 example:"blog"`
	CheckName CheckName    `yaml:"check"     mapstructure:"check"     json:"check"                example:"100percent.py"`
	UserList  UserListName `yaml:"user_list" mapstructure:"user_list" json:"user_list,omitempty"  example:"local users"`
	Timeout   float64      `yaml:"timeout"   mapstructure:"timeout"   json:"timeout,omitempty"    example:"30"`
}

ServiceSpec contains the config specification of one service. This always belongs to a box, but the object is not linked directly. Service Names are only unique per individual box.

type ServiceTemplate

type ServiceTemplate struct {
	ServiceSpec

	BoxName BoxName `json:"box"      example:"scrapyard"`
	Host    string  `json:"host"     example:"127.0.0.1"`
	TeamNum TeamNum `json:"team_num" example:"1"`
}

ServiceTemplate contains *almost* everything an agent needs to run a check. It adds variables from the box, and a specific team number. It is only missing a user, as this needs to be pulled from the db on demand.

type TeamNum

type TeamNum uint32

TeamNum is the identifier of a team. They start from 1 and go up to the configure number of teams [1, num_teams].

type User

type User struct {
	Username    string `json:"username"                    example:"geraldo"`
	Password    string `json:"password"                    example:"BuyMyNFT1!"`
	DomainName  string `json:"domain,omitempty,omitzero"   example:"quin.cy"`
	NetBIOSName string `json:"netbios,omitempty,omitzero"  example:"QUIN"`
}

User contains all the information relating to a single user.

type UserListName

type UserListName string

UserListName is the unique identifier of a userlist.

Jump to

Keyboard shortcuts

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