f-37: migration: add state change at boot #37

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-08-13 23:43:16 +02:00
commit fef04b10fc
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
3 changed files with 267 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
agentapi "git.g3e.fr/syonad/two/internal/api/agent"
configuration "git.g3e.fr/syonad/two/internal/config/agent"
dispatcher "git.g3e.fr/syonad/two/internal/dispatcher/agent"
"git.g3e.fr/syonad/two/internal/migration"
agentmetrics "git.g3e.fr/syonad/two/internal/prometheus/agent"
"git.g3e.fr/syonad/two/pkg/db/kv"
"git.g3e.fr/syonad/two/pkg/logger"
@ -31,6 +32,13 @@ func main() {
db := kv.InitDB(kv.Config{Path: cfg.Database.Path}, false)
defer db.Close()
// Avant tout démarrage de service : la DB peut porter l'ancien vocabulaire
// d'états, et des ressources transitoires orphelines d'un arrêt précédent.
if err := migration.MigrateStates(db, log.With(slog.String("component", "migration"))); err != nil {
log.Error("failed to migrate states", "error", err)
return
}
q := worker.New(cfg.Worker.BufferSize)
q.Start(cfg.Worker.Count)