Files
AetherForge c12565c83d
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Add Cloud Map seeder discovery with VPC Lattice operator templates.
Agents poll AETHERFORGE_CLOUD_MAP_ENDPOINT to sync know_node gossip; deploy plans attach route_via DNS hints for standalone operator registries.
2026-06-07 10:08:57 -07:00

66 lines
1.5 KiB
Go

package cloudmap
import "strings"
type RegistryDocument struct {
Namespace string `json:"namespace"`
Service string `json:"service"`
UpdatedAt string `json:"updated_at"`
Instances []RegistryInstance `json:"instances"`
}
type RegistryInstance struct {
AgentID string `json:"agent_id"`
DNSName string `json:"dns_name"`
IP string `json:"ip"`
FetchURL string `json:"fetch_url"`
Port int `json:"port"`
Healthy bool `json:"healthy"`
}
func SeederDNSName(service, namespace string) string {
if strings.TrimSpace(service) == "" {
service = "seeder"
}
if strings.TrimSpace(namespace) == "" {
namespace = "prod.local"
}
return strings.TrimSpace(service) + ".svc." + strings.TrimSpace(namespace)
}
func NormalizeRegistryDocument(doc RegistryDocument) (RegistryDocument, bool) {
doc.Namespace = strings.TrimSpace(doc.Namespace)
doc.Service = strings.TrimSpace(doc.Service)
if doc.Namespace == "" {
doc.Namespace = "prod.local"
}
if doc.Service == "" {
doc.Service = "seeder"
}
return doc, doc.Namespace != "" && doc.Service != ""
}
func KnowNodeTargets(doc RegistryDocument) []string {
doc, ok := NormalizeRegistryDocument(doc)
if !ok {
return nil
}
seen := make(map[string]bool)
var out []string
for _, inst := range doc.Instances {
if !inst.Healthy {
continue
}
id := strings.TrimSpace(inst.AgentID)
if id == "" {
id = strings.TrimSpace(inst.DNSName)
}
if id == "" || seen[id] {
continue
}
seen[id] = true
out = append(out, id)
}
return out
}