Parcourir la source

Expose queue health in runtime stats

tags/v0.9.0
Jan Svabenik il y a 1 mois
Parent
révision
64fa67e4d8
3 fichiers modifiés avec 39 ajouts et 1 suppressions
  1. +1
    -0
      cmd/fmrtx/main.go
  2. +36
    -0
      cmd/fmrtx/main_test.go
  3. +2
    -1
      docs/pro-runtime-hardening-workboard.md

+ 1
- 0
cmd/fmrtx/main.go Voir le fichier

@@ -254,6 +254,7 @@ func (b *txBridge) TXStats() map[string]any {
"maxGenerateMs": s.MaxGenerateMs,
"maxUpsampleMs": s.MaxUpsampleMs,
"maxWriteMs": s.MaxWriteMs,
"queue": s.Queue,
}
}
func (b *txBridge) UpdateConfig(lp ctrlpkg.LivePatch) error {


+ 36
- 0
cmd/fmrtx/main_test.go Voir le fichier

@@ -0,0 +1,36 @@
package main

import (
"testing"

apppkg "github.com/jan/fm-rds-tx/internal/app"
cfgpkg "github.com/jan/fm-rds-tx/internal/config"
"github.com/jan/fm-rds-tx/internal/output"
"github.com/jan/fm-rds-tx/internal/platform"
)

func TestTxBridgeExportsQueueStats(t *testing.T) {
cfg := cfgpkg.Default()
driver := platform.NewSimulatedDriver(nil)
engine := apppkg.NewEngine(cfg, driver)
bridge := &txBridge{engine: engine}
stats := bridge.TXStats()

raw, ok := stats["queue"]
if !ok {
t.Fatalf("expected queue stats in tx stats")
}

queue, ok := raw.(output.QueueStats)
if !ok {
t.Fatalf("queue stats type mismatch: %T", raw)
}

if queue.Capacity != cfg.Runtime.FrameQueueCapacity {
t.Fatalf("unexpected queue capacity: want %d got %d", cfg.Runtime.FrameQueueCapacity, queue.Capacity)
}

if queue.Health != output.QueueHealthCritical {
t.Fatalf("queue health should be critical with empty queue, got %s", queue.Health)
}
}

+ 2
- 1
docs/pro-runtime-hardening-workboard.md Voir le fichier

@@ -247,13 +247,14 @@ Generator/Upsampler und Hardwarewriter werden als getrennte Stufen mit kleinem,
| Datum | Entscheidung | Notiz |
|---|---|---|
| 2026-04-05 | FrameQueue mit Engine-Integration | Queue lebt nach dem Upsampler auf DeviceFrame-Ebene, Kapazität via `runtime.frameQueueCapacity`, `EngineStats` zeigt `QueueStats`, Tests decken Timeouts und Counters ab. |
| 2026-04-05 | Queue-Health-Indikator | `QueueStats.Health` gibt `critical`/`low`/`normal` zurück und ist über `EngineStats.Queue` im Runtime-Endpunkt sichtbar. |
| 2026-04-05 | Queue-Health-Indikator | `QueueStats.Health` gibt `critical`/`low`/`normal` zurück und `txBridge` leitet `EngineStats.Queue` ins `/runtime`-JSON. |

## WS-01 Verifikation
| Datum | Fokus | Ergebnis |
|---|---|---|
| 2026-04-05 | FrameQueue + Engine integration | ✅ `go test ./...` (im `internal`-Modul incl. `frame_queue_test.go`) |
| 2026-04-05 | Queue-Health-Indikator | go test ./... deckt `TestFrameQueueHealthIndicator` und `queue.health` ab. |
| 2026-04-05 | Runtime API queue health | ✅ `/runtime` liefert jetzt `engine.queue.health` dank `txBridge.TXStats`. |

---



Chargement…
Annuler
Enregistrer