ai-code-battle/cmd/acb-api/server.go
jedarden b06350d762
Some checks failed
CI / Go Tests (push) Has been cancelled
CI / Worker API Tests (push) Has been cancelled
CI / Indexer Tests (push) Has been cancelled
CI / Web Build (push) Has been cancelled
Remove legacy code: worker-api/, cmd/acb-indexer/, cluster-configuration/, gut cmd/acb-api/
Cleanup of superseded code that no longer matches the architecture:

Removed:
- worker-api/ - Cloudflare Worker with D1, superseded by K8s-based matchmaker + direct PostgreSQL
- cmd/acb-indexer/ - TypeScript index builder, superseded by Go cmd/acb-index-builder/
- cluster-configuration/ - K8s manifests belong in ardenone-cluster repo

Gutted cmd/acb-api/:
- Removed registration, job claim/result endpoints (deferred for v1)
- Removed dead code: predictions.go, seasons.go, series.go, register.go, jobs.go, glicko2.go
- API is now a stub with only health/ready endpoints
- Matchmaker and workers handle the core loop without it

Updated PROGRESS.md to reflect current architecture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 10:22:16 -04:00

33 lines
808 B
Go

package main
import (
"database/sql"
"encoding/json"
"net/http"
"github.com/redis/go-redis/v9"
)
// Server is a stub for the v1 API.
// The full API (registration, job claim/result, ratings) is deferred.
// Matchmaking is handled by acb-matchmaker; workers communicate directly with PostgreSQL.
type Server struct {
cfg Config
db *sql.DB
rdb *redis.Client
}
func (s *Server) RegisterRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /health", s.handleHealth)
mux.HandleFunc("GET /ready", s.handleReady)
}
func writeJSON(w http.ResponseWriter, status int, v any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
json.NewEncoder(w).Encode(v)
}
func writeError(w http.ResponseWriter, status int, msg string) {
writeJSON(w, status, map[string]string{"error": msg})
}