Help us shape the future of Go! Take the 2026 Go Developer Survey

gen

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	ID           int64
	Email        string
	PasswordHash string
	CreatedAt    pgtype.Timestamptz
	LastLoginAt  pgtype.Timestamptz
}

type AdminSession

type AdminSession struct {
	ID          int64
	AdminID     int64
	TokenSha256 []byte
	CreatedAt   pgtype.Timestamptz
	LastSeenAt  pgtype.Timestamptz
	ExpiresAt   pgtype.Timestamptz
	UserAgent   string
}

type AdminSessionByTokenRow

type AdminSessionByTokenRow struct {
	ID         int64
	AdminID    int64
	CreatedAt  pgtype.Timestamptz
	LastSeenAt pgtype.Timestamptz
	ExpiresAt  pgtype.Timestamptz
	Email      string
}

type AttachPairingDeviceParams

type AttachPairingDeviceParams struct {
	ID       int64
	DeviceID *int64
}

type AuditEntriesForActionParams

type AuditEntriesForActionParams struct {
	Action string
	Limit  int32
}

type AuditLog

type AuditLog struct {
	ID      int64
	At      pgtype.Timestamptz
	Actor   string
	Action  string
	Subject string
	Detail  []byte
}

type ClaimIdempotencyKeyParams

type ClaimIdempotencyKeyParams struct {
	DeviceID    int64
	Key         string
	RequestHash []byte
	ExpiresAt   pgtype.Timestamptz
}

type ClientBuild

type ClientBuild struct {
	ID            int64
	At            pgtype.Timestamptz
	Actor         string
	Address       string
	Signing       string
	Reference     string
	FileName      string
	FileBytes     int64
	Sha256        string
	ClientVersion string
	SignedBy      string
}

type ClientBuildsPageParams

type ClientBuildsPageParams struct {
	First   bool
	AfterAt pgtype.Timestamptz
	AfterID int64
	Lim     int32
}

type CoreReadDriver

type CoreReadDriver struct {
	ID         int64
	ExternalID string
	Name       string
	Slug       string
	Class      string
	AvatarUrl  string
	CreatedAt  pgtype.Timestamptz
}

type CoreReadLap

type CoreReadLap struct {
	ID         int64
	StintID    pgtype.UUID
	DriverID   int64
	Number     int32
	LapMs      int32
	Kind       string
	Sim        string
	TrackID    string
	Car        string
	CarClass   string
	Corners    []byte
	TraceBytes int32
	StartedAt  pgtype.Timestamptz
	CreatedAt  pgtype.Timestamptz
}

type CoreReadReferenceLap

type CoreReadReferenceLap struct {
	Scope     string
	Sim       string
	TrackID   string
	Car       string
	CarClass  string
	DriverID  *int64
	LapID     int64
	LapMs     int32
	UpdatedAt pgtype.Timestamptz
}

type CoreReadStint

type CoreReadStint struct {
	ID          pgtype.UUID
	DriverID    int64
	Sim         string
	TrackID     string
	Track       string
	Car         string
	CarClass    string
	SessionType string
	Sectors     []float32
	Setup       []byte
	StartedAt   pgtype.Timestamptz
	FinishedAt  pgtype.Timestamptz
	CreatedAt   pgtype.Timestamptz
}

type CoreReadStintSummary

type CoreReadStintSummary struct {
	StintID        pgtype.UUID
	Laps           int32
	Incidents      int32
	BestLapMs      int32
	AvgLapMs       int32
	ConsistencyPct int32
	TopSpeedKmh    int32
	Conditions     []byte
	CarState       []byte
	BestLapID      *int64
	FinishedAt     pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
}

type CountAllDevicesRow

type CountAllDevicesRow struct {
	Total int64
	Live  int64
}

type CreateAdminParams

type CreateAdminParams struct {
	Email        string
	PasswordHash string
}

type CreateAdminRow

type CreateAdminRow struct {
	ID        int64
	Email     string
	CreatedAt pgtype.Timestamptz
}

type CreateAdminSessionParams

type CreateAdminSessionParams struct {
	AdminID     int64
	TokenSha256 []byte
	ExpiresAt   pgtype.Timestamptz
	UserAgent   string
}

type CreateAdminSessionRow

type CreateAdminSessionRow struct {
	ID        int64
	CreatedAt pgtype.Timestamptz
	ExpiresAt pgtype.Timestamptz
}

type CreateDeviceParams

type CreateDeviceParams struct {
	DriverID    int64
	TokenSha256 []byte
	TokenPrefix string
	Label       string
}

type CreateDeviceRow

type CreateDeviceRow struct {
	ID          int64
	DriverID    int64
	TokenPrefix string
	Label       string
	CreatedAt   pgtype.Timestamptz
}

type CreateDriverParams

type CreateDriverParams struct {
	ExternalID string
	Name       string
	Slug       string
	Class      string
	AvatarUrl  string
}

type CreateDriverRow

type CreateDriverRow struct {
	ID        int64
	Name      string
	Slug      string
	Class     string
	AvatarUrl string
	CreatedAt pgtype.Timestamptz
}

type CreateDriverSessionParams

type CreateDriverSessionParams struct {
	DriverID    int64
	TokenSha256 []byte
	ExpiresAt   pgtype.Timestamptz
	UserAgent   string
	SignedInBy  string
}

type CreatePairingParams

type CreatePairingParams struct {
	DeviceCodeSha256 []byte
	UserCode         string
	ExpiresAt        pgtype.Timestamptz
}

type CreatePairingRow

type CreatePairingRow struct {
	ID        int64
	UserCode  string
	CreatedAt pgtype.Timestamptz
	ExpiresAt pgtype.Timestamptz
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DataTotalsRow

type DataTotalsRow struct {
	DatabaseBytes int64
	Drivers       int64
	Stints        int64
	OldestStintAt pgtype.Timestamptz
	Laps          int64
	Traces        int64
	TraceBytes    int64
	OldestLapAt   pgtype.Timestamptz
}

type DecidePairingParams

type DecidePairingParams struct {
	ID        int64
	Status    string
	DriverID  *int64
	DecidedBy string
}

type DeletePluginSettingParams

type DeletePluginSettingParams struct {
	PluginName string
	Name       string
}

type Device

type Device struct {
	ID          int64
	DriverID    int64
	TokenSha256 []byte
	TokenPrefix string
	Label       string
	CreatedAt   pgtype.Timestamptz
	LastUsedAt  pgtype.Timestamptz
	RevokedAt   pgtype.Timestamptz
}

type DeviceForPanelRow

type DeviceForPanelRow struct {
	ID          int64
	DriverID    int64
	DriverName  string
	TokenPrefix string
	Label       string
	CreatedAt   pgtype.Timestamptz
	LastUsedAt  pgtype.Timestamptz
	RevokedAt   pgtype.Timestamptz
}

type DevicesForDriverPageParams

type DevicesForDriverPageParams struct {
	DriverID int64
	Lim      int32
}

type DevicesForDriverPageRow

type DevicesForDriverPageRow struct {
	ID          int64
	DriverID    int64
	DriverName  string
	TokenPrefix string
	Label       string
	CreatedAt   pgtype.Timestamptz
	LastUsedAt  pgtype.Timestamptz
	RevokedAt   pgtype.Timestamptz
}

type DevicesPageParams

type DevicesPageParams struct {
	First        bool
	AfterCreated pgtype.Timestamptz
	AfterID      int64
	Lim          int32
}

type DevicesPageRow

type DevicesPageRow struct {
	ID          int64
	DriverID    int64
	DriverName  string
	TokenPrefix string
	Label       string
	CreatedAt   pgtype.Timestamptz
	LastUsedAt  pgtype.Timestamptz
	RevokedAt   pgtype.Timestamptz
}

type Driver

type Driver struct {
	ID         int64
	ExternalID string
	Name       string
	Slug       string
	Class      string
	AvatarUrl  string
	CreatedAt  pgtype.Timestamptz
}

type DriverRoster

type DriverRoster struct {
	ID             int64
	Name           string
	Slug           string
	Class          string
	CreatedAt      pgtype.Timestamptz
	Laps           int64
	TraceBytes     int64
	LastUploadAt   pgtype.Timestamptz
	Stints         int64
	Devices        int64
	RevokedDevices int64
	LastSeenAt     pgtype.Timestamptz
	SeenKey        pgtype.Timestamptz
}

type DriverSession

type DriverSession struct {
	ID          int64
	DriverID    int64
	TokenSha256 []byte
	CreatedAt   pgtype.Timestamptz
	LastSeenAt  pgtype.Timestamptz
	ExpiresAt   pgtype.Timestamptz
	UserAgent   string
	SignedInBy  string
}

type DriverSessionByTokenRow

type DriverSessionByTokenRow struct {
	ID         int64
	DriverID   int64
	CreatedAt  pgtype.Timestamptz
	LastSeenAt pgtype.Timestamptz
	ExpiresAt  pgtype.Timestamptz
	UserAgent  string
	SignedInBy string
	Slug       string
	Name       string
}

type DriverSessionsForDriverRow

type DriverSessionsForDriverRow struct {
	ID         int64
	DriverID   int64
	CreatedAt  pgtype.Timestamptz
	LastSeenAt pgtype.Timestamptz
	ExpiresAt  pgtype.Timestamptz
	UserAgent  string
	SignedInBy string
}

type DriversByLapsParams

type DriversByLapsParams struct {
	First     bool
	AfterLaps int64
	AfterID   int64
	Lim       int32
}

type DriversByLastSeenParams

type DriversByLastSeenParams struct {
	First     bool
	AfterSeen pgtype.Timestamptz
	AfterID   int64
	Lim       int32
}

type DriversByNameParams

type DriversByNameParams struct {
	First     bool
	AfterName string
	AfterID   int64
	Lim       int32
}

type FinishIdempotencyKeyParams

type FinishIdempotencyKeyParams struct {
	DeviceID     int64
	Key          string
	Status       int32
	ResponseBody []byte
}

type FinishStintParams

type FinishStintParams struct {
	ID         pgtype.UUID
	FinishedAt pgtype.Timestamptz
}

type GetPluginDatabaseRow

type GetPluginDatabaseRow struct {
	DbPasswordSealed []byte
	DbProvisioned    bool
	DbMigration      string
}

type GetPluginRow

type GetPluginRow struct {
	Name             string
	Version          string
	Author           string
	Description      string
	InterfaceVersion int32
	Capabilities     []byte
	DeclaredSettings []byte
	Directory        string
	Enabled          bool
	State            string
	LastError        string
	LastOutput       string
	Restarts         int32
	FirstSeenAt      pgtype.Timestamptz
	UpdatedAt        pgtype.Timestamptz
}

type IdempotencyKey

type IdempotencyKey struct {
	DeviceID     int64
	Key          string
	RequestHash  []byte
	Status       int32
	ResponseBody []byte
	CreatedAt    pgtype.Timestamptz
	ExpiresAt    pgtype.Timestamptz
}

type IdempotencyKeyParams

type IdempotencyKeyParams struct {
	DeviceID int64
	Key      string
}

type InsertAuditEntryParams

type InsertAuditEntryParams struct {
	Actor   string
	Action  string
	Subject string
	Detail  []byte
}

type InsertClientBuildParams

type InsertClientBuildParams struct {
	Actor         string
	Address       string
	Signing       string
	Reference     string
	FileName      string
	FileBytes     int64
	Sha256        string
	ClientVersion string
	SignedBy      string
}

type Lap

type Lap struct {
	ID            int64
	StintID       pgtype.UUID
	Number        int32
	LapMs         int32
	Kind          string
	StartedAt     pgtype.Timestamptz
	TrackID       string
	Car           string
	CarClass      string
	DriverID      int64
	ContentSha256 []byte
	TraceCodec    int16
	Trace         []byte
	CreatedAt     pgtype.Timestamptz
	TraceBytes    int32
	Sim           string
	Corners       []byte
}

type LapsForStintParams

type LapsForStintParams struct {
	StintID     pgtype.UUID
	AfterNumber int32
	Lim         int32
}

type LapsForStintRow

type LapsForStintRow struct {
	ID         int64
	Number     int32
	LapMs      int32
	Kind       string
	StartedAt  pgtype.Timestamptz
	TraceBytes int32
	CreatedAt  pgtype.Timestamptz
}

type ListDevicesForDriverRow

type ListDevicesForDriverRow struct {
	ID          int64
	DriverID    int64
	TokenPrefix string
	Label       string
	CreatedAt   pgtype.Timestamptz
	LastUsedAt  pgtype.Timestamptz
	RevokedAt   pgtype.Timestamptz
}

type ListPendingPairingsRow

type ListPendingPairingsRow struct {
	ID        int64
	UserCode  string
	CreatedAt pgtype.Timestamptz
	ExpiresAt pgtype.Timestamptz
}

type ListPluginSettingsRow

type ListPluginSettingsRow struct {
	Name   string
	Value  *string
	Sealed []byte
}

type ListPluginsRow

type ListPluginsRow struct {
	Name             string
	Version          string
	Author           string
	Description      string
	InterfaceVersion int32
	Capabilities     []byte
	DeclaredSettings []byte
	Directory        string
	Enabled          bool
	State            string
	LastError        string
	LastOutput       string
	Restarts         int32
	FirstSeenAt      pgtype.Timestamptz
	UpdatedAt        pgtype.Timestamptz
}

type LlmUsage

type LlmUsage struct {
	ID           int64
	At           pgtype.Timestamptz
	Job          string
	Model        string
	DriverID     *int64
	InputTokens  int64
	OutputTokens int64
}

type MarkSetupCompleteParams

type MarkSetupCompleteParams struct {
	CompletedBy   string
	ServerVersion string
}

type Pairing

type Pairing struct {
	ID               int64
	DeviceCodeSha256 []byte
	UserCode         string
	Status           string
	DriverID         *int64
	CreatedAt        pgtype.Timestamptz
	ExpiresAt        pgtype.Timestamptz
	DeviceID         *int64
	DecidedAt        pgtype.Timestamptz
	DecidedBy        string
}

type PairingByDeviceCodeRow

type PairingByDeviceCodeRow struct {
	ID        int64
	UserCode  string
	Status    string
	DriverID  *int64
	DeviceID  *int64
	CreatedAt pgtype.Timestamptz
	ExpiresAt pgtype.Timestamptz
}

type Plugin

type Plugin struct {
	Name             string
	Version          string
	Author           string
	Description      string
	InterfaceVersion int32
	Capabilities     []byte
	DeclaredSettings []byte
	Directory        string
	Enabled          bool
	State            string
	LastError        string
	LastOutput       string
	Restarts         int32
	FirstSeenAt      pgtype.Timestamptz
	UpdatedAt        pgtype.Timestamptz
	DbPasswordSealed []byte
	DbProvisioned    bool
	DbMigration      string
}

type PluginSetting

type PluginSetting struct {
	PluginName string
	Name       string
	Value      *string
	Sealed     []byte
	UpdatedAt  pgtype.Timestamptz
}

type PluginTokensSinceForParams

type PluginTokensSinceForParams struct {
	PluginName string
	At         pgtype.Timestamptz
}

type PluginTokensSinceForRow

type PluginTokensSinceForRow struct {
	InputTokens  int64
	OutputTokens int64
	Calls        int64
}

type PluginTokensSinceRow

type PluginTokensSinceRow struct {
	InputTokens  int64
	OutputTokens int64
	Calls        int64
}

type PluginUsage

type PluginUsage struct {
	ID           int64
	At           pgtype.Timestamptz
	PluginName   string
	Job          string
	Model        string
	DriverID     *int64
	InputTokens  int64
	OutputTokens int64
	Cached       bool
}

type PruneTracesOlderThanParams

type PruneTracesOlderThanParams struct {
	Before pgtype.Timestamptz
	Lim    int32
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AdminByEmail

func (q *Queries) AdminByEmail(ctx context.Context, lower string) (Admin, error)

The admin panel's accounts and sessions. A session cookie is stored as its SHA-256, like every other token here, so a database dump cannot be used to sign in as anyone.

func (*Queries) AdminByID

func (q *Queries) AdminByID(ctx context.Context, id int64) (Admin, error)

func (*Queries) AdminSessionByToken

func (q *Queries) AdminSessionByToken(ctx context.Context, tokenSha256 []byte) (AdminSessionByTokenRow, error)

func (*Queries) AttachPairingDevice

func (q *Queries) AttachPairingDevice(ctx context.Context, arg AttachPairingDeviceParams) error

func (*Queries) AuditEntriesForAction

func (q *Queries) AuditEntriesForAction(ctx context.Context, arg AuditEntriesForActionParams) ([]AuditLog, error)

func (*Queries) BestCleanLapMs

func (q *Queries) BestCleanLapMs(ctx context.Context, stintID pgtype.UUID) (int32, error)

func (*Queries) ClaimIdempotencyKey

func (q *Queries) ClaimIdempotencyKey(ctx context.Context, arg ClaimIdempotencyKeyParams) error

-------------------------------------------------------------------------- Idempotency --------------------------------------------------------------------------

func (*Queries) ClearPluginDatabase

func (q *Queries) ClearPluginDatabase(ctx context.Context, name string) error

func (*Queries) ClientBuildByReference

func (q *Queries) ClientBuildByReference(ctx context.Context, reference string) (ClientBuild, error)

func (*Queries) ClientBuildsPage

func (q *Queries) ClientBuildsPage(ctx context.Context, arg ClientBuildsPageParams) ([]ClientBuild, error)

func (*Queries) CountActiveDevices

func (q *Queries) CountActiveDevices(ctx context.Context) (int64, error)

func (*Queries) CountAdmins

func (q *Queries) CountAdmins(ctx context.Context) (int64, error)

func (*Queries) CountAllDevices

func (q *Queries) CountAllDevices(ctx context.Context) (CountAllDevicesRow, error)

func (*Queries) CountClientBuilds

func (q *Queries) CountClientBuilds(ctx context.Context) (int64, error)

func (*Queries) CountDrivers

func (q *Queries) CountDrivers(ctx context.Context) (int64, error)

func (*Queries) CountLaps

func (q *Queries) CountLaps(ctx context.Context) (int64, error)

func (*Queries) CountLapsForStint

func (q *Queries) CountLapsForStint(ctx context.Context, stintID pgtype.UUID) (int64, error)

func (*Queries) CountLiveDevicesForDriver

func (q *Queries) CountLiveDevicesForDriver(ctx context.Context, driverID int64) (int64, error)

func (*Queries) CountStints

func (q *Queries) CountStints(ctx context.Context) (int64, error)

func (*Queries) CreateAdmin

func (q *Queries) CreateAdmin(ctx context.Context, arg CreateAdminParams) (CreateAdminRow, error)

func (*Queries) CreateAdminSession

func (q *Queries) CreateAdminSession(ctx context.Context, arg CreateAdminSessionParams) (CreateAdminSessionRow, error)

func (*Queries) CreateDevice

func (q *Queries) CreateDevice(ctx context.Context, arg CreateDeviceParams) (CreateDeviceRow, error)

Device tokens: the row holds only a SHA-256 and a short clear-text prefix for the lookup index. The pairing endpoints that mint these are not built yet; the table and the queries are.

func (*Queries) CreateDriver

func (q *Queries) CreateDriver(ctx context.Context, arg CreateDriverParams) (CreateDriverRow, error)

func (*Queries) CreateDriverSession

func (q *Queries) CreateDriverSession(ctx context.Context, arg CreateDriverSessionParams) error

A driver signed in to a browser. The lookup enforces expiry itself, so there is no window in which an old cookie works.

func (*Queries) CreatePairing

func (q *Queries) CreatePairing(ctx context.Context, arg CreatePairingParams) (CreatePairingRow, error)

The queries API v1 runs. Everything here is a single statement against an index; the parts of the ingest path that cannot be written this way — the temporary table a COPY lands in, which sqlc cannot see because it exists only inside one transaction — are in laps.go beside the code that runs them. -------------------------------------------------------------------------- Pairing --------------------------------------------------------------------------

func (*Queries) DataTotals

func (q *Queries) DataTotals(ctx context.Context) (DataTotalsRow, error)

-------------------------------------------------------------------------- What is stored, and what it costs -------------------------------------------------------------------------- Every figure on the data page, in one statement. The three scalar subqueries are each a single aggregate over a small table; the rest is one pass over laps, which is the table the page is actually about.

func (*Queries) DatabaseSizeBytes

func (q *Queries) DatabaseSizeBytes(ctx context.Context) (int64, error)

What the admin panel's overview page shows. Every one of these is a single statement, because the page is loaded by someone waiting for it.

func (*Queries) DecidePairing

func (q *Queries) DecidePairing(ctx context.Context, arg DecidePairingParams) (int64, error)

func (*Queries) DeleteAdminSession

func (q *Queries) DeleteAdminSession(ctx context.Context, tokenSha256 []byte) error

func (*Queries) DeleteAdminSessionsForAdmin

func (q *Queries) DeleteAdminSessionsForAdmin(ctx context.Context, adminID int64) (int64, error)

func (*Queries) DeleteDriverSession

func (q *Queries) DeleteDriverSession(ctx context.Context, tokenSha256 []byte) error

func (*Queries) DeleteDriverSessionByID

func (q *Queries) DeleteDriverSessionByID(ctx context.Context, id int64) (int64, error)

func (*Queries) DeleteDriverSessionsForDriver

func (q *Queries) DeleteDriverSessionsForDriver(ctx context.Context, driverID int64) (int64, error)

func (*Queries) DeleteExpiredAdminSessions

func (q *Queries) DeleteExpiredAdminSessions(ctx context.Context) (int64, error)

func (*Queries) DeleteExpiredDriverSessions

func (q *Queries) DeleteExpiredDriverSessions(ctx context.Context) (int64, error)

func (*Queries) DeleteExpiredIdempotencyKeys

func (q *Queries) DeleteExpiredIdempotencyKeys(ctx context.Context, expiresAt pgtype.Timestamptz) (int64, error)

func (*Queries) DeleteFinishedPairings

func (q *Queries) DeleteFinishedPairings(ctx context.Context, expiresAt pgtype.Timestamptz) (int64, error)

func (*Queries) DeletePlugin

func (q *Queries) DeletePlugin(ctx context.Context, name string) error

func (*Queries) DeletePluginSetting

func (q *Queries) DeletePluginSetting(ctx context.Context, arg DeletePluginSettingParams) error

func (*Queries) DeleteSetting

func (q *Queries) DeleteSetting(ctx context.Context, key string) error

func (*Queries) DeleteSigningCertificate

func (q *Queries) DeleteSigningCertificate(ctx context.Context) error

func (*Queries) DeviceForPanel

func (q *Queries) DeviceForPanel(ctx context.Context, id int64) (DeviceForPanelRow, error)

func (*Queries) DevicesByTokenPrefix

func (q *Queries) DevicesByTokenPrefix(ctx context.Context, tokenPrefix string) ([]Device, error)

func (*Queries) DevicesForDriverPage

func (q *Queries) DevicesForDriverPage(ctx context.Context, arg DevicesForDriverPageParams) ([]DevicesForDriverPageRow, error)

func (*Queries) DevicesPage

func (q *Queries) DevicesPage(ctx context.Context, arg DevicesPageParams) ([]DevicesPageRow, error)

-------------------------------------------------------------------------- Devices --------------------------------------------------------------------------

func (*Queries) DriverByID

func (q *Queries) DriverByID(ctx context.Context, id int64) (Driver, error)

-------------------------------------------------------------------------- Drivers --------------------------------------------------------------------------

func (*Queries) DriverBySlug

func (q *Queries) DriverBySlug(ctx context.Context, slug string) (Driver, error)

func (*Queries) DriverRosterByID

func (q *Queries) DriverRosterByID(ctx context.Context, id int64) (DriverRoster, error)

func (*Queries) DriverSessionByToken

func (q *Queries) DriverSessionByToken(ctx context.Context, tokenSha256 []byte) (DriverSessionByTokenRow, error)

func (*Queries) DriverSessionsForDriver

func (q *Queries) DriverSessionsForDriver(ctx context.Context, driverID int64) ([]DriverSessionsForDriverRow, error)

func (*Queries) DriversByLaps

func (q *Queries) DriversByLaps(ctx context.Context, arg DriversByLapsParams) ([]DriverRoster, error)

func (*Queries) DriversByLastSeen

func (q *Queries) DriversByLastSeen(ctx context.Context, arg DriversByLastSeenParams) ([]DriverRoster, error)

func (*Queries) DriversByName

func (q *Queries) DriversByName(ctx context.Context, arg DriversByNameParams) ([]DriverRoster, error)

What the drivers, devices and data pages read. Three rules hold across all of them, because an admin page is loaded by a person waiting for it:

  • one query per page, never one per row. Every count, sum and "last seen" on a page comes back from a single statement, so the cost of the page does not grow with the number of rows on it;
  • keyset pagination, never OFFSET. A cursor is the last row's sort key, so page fifty costs what page one costs and a row inserted mid-read cannot shuffle a driver onto two pages or off both;
  • the first page says so with a boolean rather than with a sentinel value, because there is no value of a name or a timestamp that reliably sorts before every real one.

-------------------------------------------------------------------------- The roster -------------------------------------------------------------------------- Three orderings of one view, spelled out rather than assembled from a sort parameter: the ORDER BY and the keyset predicate have to agree on direction and on tie-break, and a CASE that got that wrong would page silently past rows rather than fail.

func (*Queries) ExpirePairing

func (q *Queries) ExpirePairing(ctx context.Context, id int64) error

func (*Queries) FinishIdempotencyKey

func (q *Queries) FinishIdempotencyKey(ctx context.Context, arg FinishIdempotencyKeyParams) error

func (*Queries) FinishStint

func (q *Queries) FinishStint(ctx context.Context, arg FinishStintParams) error

func (*Queries) GetPlugin

func (q *Queries) GetPlugin(ctx context.Context, name string) (GetPluginRow, error)

func (*Queries) GetPluginDatabase

func (q *Queries) GetPluginDatabase(ctx context.Context, name string) (GetPluginDatabaseRow, error)

The plugin's own database. Separate queries rather than columns on the ones above: every reader of a plugin row wants its name and state, and almost none of them want a sealed password. Keeping it out of the common path means it is not accidentally logged by something that dumps a struct.

func (*Queries) GetSetting

func (q *Queries) GetSetting(ctx context.Context, key string) ([]byte, error)

The settings table is the organisation's own configuration: what drivers see, how the server is reached, and the encrypted API key. It outlives the data directory, which is the point.

func (*Queries) IdempotencyKey

func (q *Queries) IdempotencyKey(ctx context.Context, arg IdempotencyKeyParams) (IdempotencyKey, error)

func (*Queries) InsertAuditEntry

func (q *Queries) InsertAuditEntry(ctx context.Context, arg InsertAuditEntryParams) (AuditLog, error)

The audit trail. Every change an administrator makes in the panel writes one row here: who, what, and when. The detail column names the fields that changed and never carries their values, because a settings change can be a change to an API key.

func (*Queries) InsertClientBuild

func (q *Queries) InsertClientBuild(ctx context.Context, arg InsertClientBuildParams) (ClientBuild, error)

The build history. Keyset pagination, newest first, over the index the migration creates: page fifty costs what page one costs, and a build made while an operator is reading cannot shuffle a row onto two pages or off both.

func (*Queries) LapsForStint

func (q *Queries) LapsForStint(ctx context.Context, arg LapsForStintParams) ([]LapsForStintRow, error)

Lap numbers are unique within a stint and start at zero, so the cursor is the last number rendered and -1 is "from the beginning". No boolean is needed here: there is a value below every real one, which is the case the roster queries above do not have.

func (*Queries) ListDevicesForDriver

func (q *Queries) ListDevicesForDriver(ctx context.Context, driverID int64) ([]ListDevicesForDriverRow, error)

func (*Queries) ListDrivers

func (q *Queries) ListDrivers(ctx context.Context) ([]Driver, error)

func (*Queries) ListPendingPairings

func (q *Queries) ListPendingPairings(ctx context.Context) ([]ListPendingPairingsRow, error)

func (*Queries) ListPluginSettings

func (q *Queries) ListPluginSettings(ctx context.Context, pluginName string) ([]ListPluginSettingsRow, error)

func (*Queries) ListPlugins

func (q *Queries) ListPlugins(ctx context.Context) ([]ListPluginsRow, error)

func (*Queries) ListSettings

func (q *Queries) ListSettings(ctx context.Context) ([]Setting, error)

func (*Queries) MarkSetupComplete

func (q *Queries) MarkSetupComplete(ctx context.Context, arg MarkSetupCompleteParams) (pgtype.Timestamptz, error)

func (*Queries) PairingByDeviceCode

func (q *Queries) PairingByDeviceCode(ctx context.Context, deviceCodeSha256 []byte) (PairingByDeviceCodeRow, error)

func (*Queries) PluginTokensSince

func (q *Queries) PluginTokensSince(ctx context.Context, at pgtype.Timestamptz) (PluginTokensSinceRow, error)

func (*Queries) PluginTokensSinceFor

func (q *Queries) PluginTokensSinceFor(ctx context.Context, arg PluginTokensSinceForParams) (PluginTokensSinceForRow, error)

func (*Queries) PruneTracesOlderThan

func (q *Queries) PruneTracesOlderThan(ctx context.Context, arg PruneTracesOlderThanParams) (int64, error)

One batch of the prune. The lap row stays and so does its time: only the blob goes, and trace_codec goes to zero because no codec wrote the empty trace — version one is the lowest a real one carries.

The reference rows for those laps are deleted in the same statement. A reference lap is fetched whole and decoded, so leaving one pointing at a cleared blob would turn a driver's next coaching request into a server error; deleting it makes the bucket empty, which is an ordinary answer the next upload refills.

func (*Queries) RecentAuditEntries

func (q *Queries) RecentAuditEntries(ctx context.Context, limit int32) ([]AuditLog, error)

func (*Queries) RecordPluginUsage

func (q *Queries) RecordPluginUsage(ctx context.Context, arg RecordPluginUsageParams) error

func (*Queries) RecordTokenUsage

func (q *Queries) RecordTokenUsage(ctx context.Context, arg RecordTokenUsageParams) error

What the language-model features have spent. One row per call, summed over a window for the settings page and for the operator's daily cap.

func (*Queries) ReferenceLap

func (q *Queries) ReferenceLap(ctx context.Context, arg ReferenceLapParams) (ReferenceLapRow, error)

-------------------------------------------------------------------------- Reference laps -------------------------------------------------------------------------- Three index lookups and a sort of at most three rows. Each branch reads one entry of one of the two partial unique indexes on reference_laps, so the cost does not grow with the number of laps ever driven — which is the whole reason the table is maintained on insert.

The preference array decides the winner: the requested scope first, then the narrower ones, so a server with no class data still answers with the driver's own best rather than a 404.

Every branch is scoped by the simulator, and that is not an optimisation. Two simulators agree about the slug of a circuit and the name of a car and agree about nothing underneath, so a lap from one is not a reference for a lap from the other and a lookup that crossed that line would answer with a time nobody driving this simulator has ever set.

func (*Queries) ReplaceStintSummary

func (q *Queries) ReplaceStintSummary(ctx context.Context, arg ReplaceStintSummaryParams) error

-------------------------------------------------------------------------- Summaries -------------------------------------------------------------------------- Whole-document replace, so a retry can never merge two halves of two different states: every column is in the update list.

func (*Queries) RevokeAllDevices

func (q *Queries) RevokeAllDevices(ctx context.Context) (int64, error)

func (*Queries) RevokeDevice

func (q *Queries) RevokeDevice(ctx context.Context, id int64) (int64, error)

func (*Queries) RevokeDevicesForDriver

func (q *Queries) RevokeDevicesForDriver(ctx context.Context, driverID int64) (int64, error)

Revoking is scoped to one driver and touches nothing else, which is the whole point of the lost-laptop action: it is not the danger zone's "revoke everything", and no other driver stops uploading because of it.

func (*Queries) SaveSigningCertificate

func (q *Queries) SaveSigningCertificate(ctx context.Context, arg SaveSigningCertificateParams) error

The operator's code-signing certificate. One row, replaced whole: uploading a certificate replaces whatever was there, because a server signs with one.

func (*Queries) SetAdminPasswordHash

func (q *Queries) SetAdminPasswordHash(ctx context.Context, arg SetAdminPasswordHashParams) error

func (*Queries) SetPluginEnabled

func (q *Queries) SetPluginEnabled(ctx context.Context, arg SetPluginEnabledParams) error

func (*Queries) SetPluginProvisioned

func (q *Queries) SetPluginProvisioned(ctx context.Context, arg SetPluginProvisionedParams) error

func (*Queries) SetPluginSettings

func (q *Queries) SetPluginSettings(ctx context.Context, arg SetPluginSettingsParams) error

func (*Queries) SetPluginState

func (q *Queries) SetPluginState(ctx context.Context, arg SetPluginStateParams) error

func (*Queries) SetupCompletedAt

func (q *Queries) SetupCompletedAt(ctx context.Context) (pgtype.Timestamptz, error)

Setup runs once, and this is where that is decided. The row in setup_state is written in the same transaction as the first administrator, so a half-finished setup leaves neither behind.

func (*Queries) SigningCertificate

func (q *Queries) SigningCertificate(ctx context.Context) (SigningCertificate, error)

func (*Queries) StintForDriver

func (q *Queries) StintForDriver(ctx context.Context, arg StintForDriverParams) (StintForDriverRow, error)

The sim comes back with the rest of the identity because every lap written against this stint copies it down, and because the reference lookup the coach runs is scoped by it.

The setup comes back with it because the facts a finished stint produces carry it, and that read happens inside the same transaction as the write it belongs to.

func (*Queries) StintForPanel

func (q *Queries) StintForPanel(ctx context.Context, id pgtype.UUID) (StintForPanelRow, error)

func (*Queries) StintsForDriver

func (q *Queries) StintsForDriver(ctx context.Context, arg StintsForDriverParams) ([]StintsForDriverRow, error)

-------------------------------------------------------------------------- A driver's stints, and a stint's laps -------------------------------------------------------------------------- The lateral is per stint on the page and not per stint in the table: the keyset above it has already cut the set to one page, so this reads the laps of twenty-odd stints through laps (stint_id, number) and stops.

func (*Queries) StorageByDriver

func (q *Queries) StorageByDriver(ctx context.Context, limit int32) ([]StorageByDriverRow, error)

func (*Queries) TokensSince

func (q *Queries) TokensSince(ctx context.Context, at pgtype.Timestamptz) (TokensSinceRow, error)

func (*Queries) TouchAdminLogin

func (q *Queries) TouchAdminLogin(ctx context.Context, id int64) error

func (*Queries) TouchAdminSession

func (q *Queries) TouchAdminSession(ctx context.Context, arg TouchAdminSessionParams) error

func (*Queries) TouchDevice

func (q *Queries) TouchDevice(ctx context.Context, id int64) error

func (*Queries) TouchDriverSession

func (q *Queries) TouchDriverSession(ctx context.Context, arg TouchDriverSessionParams) error

func (*Queries) TraceBytes

func (q *Queries) TraceBytes(ctx context.Context) (int64, error)

func (*Queries) TracesOlderThan

func (q *Queries) TracesOlderThan(ctx context.Context, startedAt pgtype.Timestamptz) (TracesOlderThanRow, error)

The retention preview and the prune read one set through one index: laps older than the cutoff that still hold a trace. They must agree exactly, or the page would promise one number and the job would do another.

func (*Queries) UpsertPlugin

func (q *Queries) UpsertPlugin(ctx context.Context, arg UpsertPluginParams) error

Plugins: what is installed, what the operator configured, and what each one spent. The host in internal/plugins is the only caller.

func (*Queries) UpsertPluginSetting

func (q *Queries) UpsertPluginSetting(ctx context.Context, arg UpsertPluginSettingParams) error

func (*Queries) UpsertSetting

func (q *Queries) UpsertSetting(ctx context.Context, arg UpsertSettingParams) error

func (*Queries) UpsertStint

func (q *Queries) UpsertStint(ctx context.Context, arg UpsertStintParams) (UpsertStintRow, error)

-------------------------------------------------------------------------- Stints -------------------------------------------------------------------------- The DO UPDATE carries a WHERE on the owner, so a stint id that already belongs to another driver updates nothing and returns no row. The caller reads that as "no such stint", which is the right answer: a client must not learn that somebody else's identifier exists.

setup is updated like every other mutable field, and a client that sends the stint again without one clears it. That is the right way round: the setup a stint was driven on is whatever the client last said it was, and a client that has stopped seeing one is telling us something.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RecordPluginUsageParams

type RecordPluginUsageParams struct {
	PluginName   string
	Job          string
	Model        string
	DriverID     *int64
	InputTokens  int64
	OutputTokens int64
	Cached       bool
}

type RecordTokenUsageParams

type RecordTokenUsageParams struct {
	Job          string
	Model        string
	DriverID     *int64
	InputTokens  int64
	OutputTokens int64
}

type ReferenceLap

type ReferenceLap struct {
	Scope     string
	TrackID   string
	Car       string
	CarClass  string
	DriverID  *int64
	LapID     int64
	LapMs     int32
	UpdatedAt pgtype.Timestamptz
	Sim       string
}

type ReferenceLapParams

type ReferenceLapParams struct {
	DriverID   int64
	Sim        string
	TrackID    string
	Car        string
	CarClass   string
	Preference []string
}

type ReferenceLapRow

type ReferenceLapRow struct {
	Scope      string
	LapMs      int32
	DriverID   int64
	DriverName string
	TraceCodec int16
	Trace      []byte
}

type ReplaceStintSummaryParams

type ReplaceStintSummaryParams struct {
	StintID        pgtype.UUID
	Laps           int32
	Incidents      int32
	BestLapMs      int32
	AvgLapMs       int32
	ConsistencyPct int32
	TopSpeedKmh    int32
	Conditions     []byte
	CarState       []byte
	BestTrace      []byte
	BestTraceCodec int16
	FinishedAt     pgtype.Timestamptz
}

type SaveSigningCertificateParams

type SaveSigningCertificateParams struct {
	PfxSealed      []byte
	PasswordSealed []byte
	Subject        string
	Issuer         string
	NotBefore      pgtype.Timestamptz
	NotAfter       pgtype.Timestamptz
	Thumbprint     string
	Algorithm      string
	SelfSigned     bool
	CodeSigning    bool
	UploadedBy     string
}

type SetAdminPasswordHashParams

type SetAdminPasswordHashParams struct {
	ID           int64
	PasswordHash string
}

type SetPluginEnabledParams

type SetPluginEnabledParams struct {
	Name    string
	Enabled bool
}

type SetPluginProvisionedParams

type SetPluginProvisionedParams struct {
	Name             string
	DbPasswordSealed []byte
	DbMigration      string
}

type SetPluginSettingsParams

type SetPluginSettingsParams struct {
	Name             string
	DeclaredSettings []byte
}

type SetPluginStateParams

type SetPluginStateParams struct {
	Name       string
	State      string
	LastError  string
	LastOutput string
	Restarts   int32
}

type Setting

type Setting struct {
	Key       string
	Value     []byte
	UpdatedAt pgtype.Timestamptz
}

type SetupState

type SetupState struct {
	ID            bool
	CompletedAt   pgtype.Timestamptz
	CompletedBy   string
	ServerVersion string
}

type SigningCertificate

type SigningCertificate struct {
	ID             int16
	PfxSealed      []byte
	PasswordSealed []byte
	Subject        string
	Issuer         string
	NotBefore      pgtype.Timestamptz
	NotAfter       pgtype.Timestamptz
	Thumbprint     string
	Algorithm      string
	SelfSigned     bool
	CodeSigning    bool
	UploadedAt     pgtype.Timestamptz
	UploadedBy     string
}

type Stint

type Stint struct {
	ID          pgtype.UUID
	DriverID    int64
	Sim         string
	TrackID     string
	Track       string
	Car         string
	CarClass    string
	SessionType string
	Sectors     []float32
	StartedAt   pgtype.Timestamptz
	FinishedAt  pgtype.Timestamptz
	CreatedAt   pgtype.Timestamptz
	Setup       []byte
}

type StintForDriverParams

type StintForDriverParams struct {
	ID       pgtype.UUID
	DriverID int64
}

type StintForDriverRow

type StintForDriverRow struct {
	ID         pgtype.UUID
	DriverID   int64
	Sim        string
	TrackID    string
	Car        string
	CarClass   string
	StartedAt  pgtype.Timestamptz
	FinishedAt pgtype.Timestamptz
	Setup      []byte
}

type StintForPanelRow

type StintForPanelRow struct {
	ID          pgtype.UUID
	DriverID    int64
	DriverName  string
	Sim         string
	Track       string
	TrackID     string
	Car         string
	CarClass    string
	SessionType string
	StartedAt   pgtype.Timestamptz
	FinishedAt  pgtype.Timestamptz
	Laps        int64
	BestLapMs   int32
	TraceBytes  int64
}

type StintSummary

type StintSummary struct {
	StintID        pgtype.UUID
	Laps           int32
	Incidents      int32
	BestLapMs      int32
	AvgLapMs       int32
	ConsistencyPct int32
	TopSpeedKmh    int32
	Conditions     []byte
	CarState       []byte
	BestLapID      *int64
	FinishedAt     pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
	BestTrace      []byte
	BestTraceCodec int16
}

type StintsForDriverParams

type StintsForDriverParams struct {
	DriverID     int64
	First        bool
	AfterStarted pgtype.Timestamptz
	AfterID      pgtype.UUID
	Lim          int32
}

type StintsForDriverRow

type StintsForDriverRow struct {
	ID          pgtype.UUID
	Track       string
	Car         string
	CarClass    string
	SessionType string
	StartedAt   pgtype.Timestamptz
	FinishedAt  pgtype.Timestamptz
	Laps        int64
	BestLapMs   int32
	TraceBytes  int64
}

type StorageByDriverRow

type StorageByDriverRow struct {
	ID         int64
	Name       string
	Laps       int64
	TraceBytes int64
}

type TokensSinceRow

type TokensSinceRow struct {
	InputTokens  int64
	OutputTokens int64
	Calls        int64
}

type TouchAdminSessionParams

type TouchAdminSessionParams struct {
	TokenSha256 []byte
	ExpiresAt   pgtype.Timestamptz
}

type TouchDriverSessionParams

type TouchDriverSessionParams struct {
	TokenSha256 []byte
	ExpiresAt   pgtype.Timestamptz
}

type TracesOlderThanRow

type TracesOlderThanRow struct {
	Laps       int64
	TraceBytes int64
	OldestAt   pgtype.Timestamptz
	NewestAt   pgtype.Timestamptz
}

type UpsertPluginParams

type UpsertPluginParams struct {
	Name             string
	Version          string
	Author           string
	Description      string
	InterfaceVersion int32
	Capabilities     []byte
	DeclaredSettings []byte
	Directory        string
	State            string
}

type UpsertPluginSettingParams

type UpsertPluginSettingParams struct {
	PluginName string
	Name       string
	Value      *string
	Sealed     []byte
}

type UpsertSettingParams

type UpsertSettingParams struct {
	Key   string
	Value []byte
}

type UpsertStintParams

type UpsertStintParams struct {
	ID          pgtype.UUID
	DriverID    int64
	Sim         string
	TrackID     string
	Track       string
	Car         string
	CarClass    string
	SessionType string
	Sectors     []float32
	StartedAt   pgtype.Timestamptz
	Setup       []byte
}

type UpsertStintRow

type UpsertStintRow struct {
	ID       pgtype.UUID
	DriverID int64
}

Jump to

Keyboard shortcuts

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