Documentation
¶
Overview ¶
Package workload ejerce el dominio de la superapp a ALTO VOLUMEN —datos relacionados, consultas, transacciones y caché— y recolecta métricas para un informe ejecutivo. El recorder (S2) es la fuente de latencias y perfil SQL: captura cada statement con su duración, op y filas. La caché (in-memory o Redis) y el logger los instala el caller; aquí solo se ejerce la superficie.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Engine string // etiqueta del motor (sqlite/postgres/…)
Scale int // multiplicador de volumen (>=1)
}
Config parametriza la corrida.
type LatencyStat ¶
type LatencyStat struct {
Count int `json:"count"`
P50 float64 `json:"p50_ms"`
P95 float64 `json:"p95_ms"`
P99 float64 `json:"p99_ms"`
Max float64 `json:"max_ms"`
}
LatencyStat son percentiles de latencia (ms) de un grupo de statements.
type Result ¶
type Result struct {
Engine string `json:"engine"`
Scale int `json:"scale"`
StartedAt time.Time `json:"started_at"`
SeedDuration time.Duration `json:"seed_duration_ns"`
WorkDuration time.Duration `json:"work_duration_ns"`
TotalDuration time.Duration `json:"total_duration_ns"`
Volume map[string]int64 `json:"volume"`
TotalRows int64 `json:"total_rows"`
OpsByCategory map[string]int `json:"ops_by_category"`
Transactions int `json:"transactions"`
Errors int `json:"errors"`
StmtsByOp map[string]int `json:"stmts_by_op"`
TotalStmts int `json:"total_stmts"`
RowsSelected int64 `json:"rows_selected"` // filas devueltas por SELECT (lecturas reales)
RowsReturned int64 `json:"rows_returned"` // filas devueltas por INSERT/UPDATE/DELETE … RETURNING
Latency map[string]LatencyStat `json:"latency"` // exec/query/query_row/overall
CacheableReads int `json:"cacheable_reads"`
CacheHits int `json:"cache_hits"`
}
Result reúne todas las métricas de una corrida (se serializa a metrics.json y alimenta el informe ejecutivo).
func Run ¶
func Run(ctx context.Context, cfg Config, client *quark.Client, rec *recorder.Recorder, log *slog.Logger) (*Result, error)
Run ejecuta el seed de alto volumen + la mezcla de carga y devuelve las métricas. client debe traer instalado el recorder rec (vía rec.Options()).
func (*Result) CacheHitRate ¶
CacheHitRate devuelve el ratio de aciertos de caché [0,1].
func (*Result) ExecutiveReport ¶
ExecutiveReport renderiza el informe ejecutivo en Markdown.
func (*Result) QueriesPerSec ¶
func (*Result) RowsPerSec ¶
RowsPerSec y QueriesPerSec son throughput sobre el wall-clock total.
func (*Result) WriteArtifacts ¶
WriteArtifacts vuelca metrics.json y el informe ejecutivo (executive-report.md) a outDir. logPath es la ruta del log que el caller ya escribió (se enlaza en el informe). Devuelve las rutas resultantes.