Record project continuation changes

This commit is contained in:
2026-05-12 21:02:29 +03:00
parent 3059d1d7a3
commit 8f69d53193
339 changed files with 101111 additions and 1769 deletions
+33
View File
@@ -2,6 +2,7 @@ package runtime
import (
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
@@ -208,6 +209,7 @@ func buildRouter(logger *slog.Logger, modules ...module.Module) http.Handler {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ready"))
})
router.Post("/mesh/v1/health", controlPlaneMeshHealth)
router.Route("/api/v1", func(r chi.Router) {
for _, mod := range modules {
@@ -218,3 +220,34 @@ func buildRouter(logger *slog.Logger, modules ...module.Module) http.Handler {
return router
}
func controlPlaneMeshHealth(w http.ResponseWriter, r *http.Request) {
var message struct {
ProtocolVersion string `json:"protocol_version"`
From struct {
ClusterID string `json:"cluster_id"`
NodeID string `json:"node_id"`
} `json:"from"`
To struct {
ClusterID string `json:"cluster_id"`
NodeID string `json:"node_id"`
} `json:"to"`
}
if err := json.NewDecoder(r.Body).Decode(&message); err != nil {
http.Error(w, "invalid mesh health message", http.StatusBadRequest)
return
}
if message.ProtocolVersion != "mesh-control-v1" || message.From.ClusterID == "" || message.From.NodeID == "" {
http.Error(w, "invalid mesh health message", http.StatusBadRequest)
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]any{
"protocol_version": "mesh-control-v1",
"accepted": true,
"by": map[string]string{
"cluster_id": message.From.ClusterID,
"node_id": "control-plane-relay",
},
})
}