f-21: refactor: add dispatcher layer for MQTT migration

Introduce internal/dispatcher package with a Command interface and typed
commands (CreateVPC, DeleteVPC, CreateSubnet, DeleteSubnet). The API
handlers now call dispatcher.Dispatch() instead of enqueuing closures
directly, decoupling transport (HTTP today, MQTT tomorrow) from execution.

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-04-19 00:06:50 +02:00
commit 63a288f69e
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
9 changed files with 114 additions and 39 deletions

View file

@ -7,6 +7,7 @@ import (
agentapi "git.g3e.fr/syonad/two/internal/api/agent"
configuration "git.g3e.fr/syonad/two/internal/config/agent"
"git.g3e.fr/syonad/two/internal/dispatcher"
agentmetrics "git.g3e.fr/syonad/two/internal/prometheus/agent"
"git.g3e.fr/syonad/two/pkg/db/kv"
promserver "git.g3e.fr/syonad/two/pkg/prometheus"
@ -35,7 +36,8 @@ func main() {
apiAddr := fmt.Sprintf("%s:%d", cfg.Api.Address, cfg.Api.Port)
promAddr := fmt.Sprintf("%s:%d", cfg.Prometheus.Address, cfg.Prometheus.Port)
go agentapi.New(q, db).Start(apiAddr)
d := dispatcher.New(q, db)
go agentapi.New(d, db).Start(apiAddr)
go promserver.Start(promAddr, registry)
select {}