catalogue

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package catalogue holds shared helpers for the investor benchmark catalogue artifact: cross-process atomic JSON merge (soak loops) and Pushgateway push.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicMergeJSON

func AtomicMergeJSON(path string, merge MergeFunc) error

AtomicMergeJSON reads path (if present), applies merge, and writes the result via temp file + rename. A sibling <path>.lock file is flock'd for the duration so concurrent soak-loop passes cannot interleave writes.

func FormatGauge

func FormatGauge(name string, value float64, labels map[string]string) string

FormatGauge renders a single Prometheus gauge line (no HELP/TYPE).

func FormatPercentileGauges

func FormatPercentileGauges(metricPrefix, runtime string, p50, p90, p99 int64) string

FormatPercentileGauges emits p50/p90/p99 gauges for a runtime label.

func MergeEntriesDocument

func MergeEntriesDocument(existing []byte, scenario string, entries []Entry) ([]byte, error)

MergeEntriesDocument merges catalogue entry slices keyed by entry ID.

func PushSimHeartbeat

func PushSimHeartbeat(simID string) error

PushSimHeartbeat fires a best-effort liveness gauge for one sim. It is fire-and-forget: it never blocks the caller and never fails a run — losing a heartbeat is harmless, stalling a run is not. The push runs in the background with a short timeout, and a single failure disables further heartbeats so an unreachable Pushgateway can't spawn a doomed goroutine per remaining sim.

func PushText

func PushText(job, instance, body string) error

PushText posts Prometheus text exposition to Pushgateway job/instance.

func PushgatewayURL

func PushgatewayURL() string

PushgatewayURL reads AEROL_PUSHGATEWAY_URL. Empty means push is disabled.

func RenderMarkdown

func RenderMarkdown(scenario string, doc Document) string

RenderMarkdown builds the investor catalogue report grouped by category.

func SortEntries

func SortEntries(entries []Entry)

SortEntries sorts entries by category, subcategory, id for stable output.

Types

type Document

type Document struct {
	Scenario    string         `json:"scenario"`
	GeneratedAt string         `json:"generated_at"`
	Entries     []Entry        `json:"entries"`
	Summary     Summary        `json:"summary"`
	Machine     map[string]any `json:"machine,omitempty"`
}

Document is the on-disk catalogue JSON shape.

type Entry

type Entry struct {
	ID          string `json:"id"`
	Question    string `json:"question"`
	Category    string `json:"category"`
	Subcategory string `json:"subcategory,omitempty"`
	Runtime     string `json:"runtime,omitempty"`
	Scenario    string `json:"scenario"`
	LatencyMS   int64  `json:"latency_ms,omitempty"`
	Success     bool   `json:"success"`
	Skipped     bool   `json:"skipped,omitempty"`
	PublicURL   string `json:"public_url,omitempty"`
	Artifact    string `json:"artifact,omitempty"`
	Notes       string `json:"notes,omitempty"`
	SimID       string `json:"sim_id,omitempty"`
}

Entry is one executed catalogue question recorded into the JSON artifact.

type MergeFunc

type MergeFunc func(existing []byte) ([]byte, error)

MergeFunc receives the existing JSON bytes (nil/empty on first write) and returns the merged document to persist.

type Summary

type Summary struct {
	Total      int            `json:"total"`
	Passed     int            `json:"passed"`
	Failed     int            `json:"failed"`
	Skipped    int            `json:"skipped"`
	ByCategory map[string]int `json:"by_category"`
}

Summary rolls up entry outcomes.

func Summarize

func Summarize(entries []Entry) Summary

Summarize builds a summary from entries.

Directories

Path Synopsis
cmd
gen command
Command gen renders reports/<scenario>-catalogue.md from catalogue JSON.
Command gen renders reports/<scenario>-catalogue.md from catalogue JSON.

Jump to

Keyboard shortcuts

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