Files
smueller b335f6a497
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 9s
CI / Go — edge-gateway build (push) Successful in 17s
Phase8
2026-06-26 13:33:03 +02:00

38 lines
922 B
Go

package config
import (
"os"
"strconv"
"time"
)
type Config struct {
ListenAddr string
APIURL string
EdgeKey string
PlayDomain string
StartWait time.Duration
PollInterval time.Duration
}
func Load() Config {
startWaitSec, _ := strconv.Atoi(envOr("EDGE_START_WAIT_SECONDS", "180"))
pollMs, _ := strconv.Atoi(envOr("EDGE_POLL_INTERVAL_MS", "2000"))
return Config{
ListenAddr: envOr("EDGE_LISTEN_ADDR", ":25565"),
APIURL: envOr("API_URL", "http://localhost:3001"),
EdgeKey: envOr("EDGE_INTERNAL_API_KEY", "local-dev-edge-key-change-me-32chars"),
PlayDomain: envOr("GAME_BASE_DOMAIN", "play.example.net"),
StartWait: time.Duration(startWaitSec) * time.Second,
PollInterval: time.Duration(pollMs) * time.Millisecond,
}
}
func envOr(key, fallback string) string {
if value := os.Getenv(key); value != "" {
return value
}
return fallback
}