Architecture conformance fix per plan §12 Phase 4: - Plan specifies Matchmaker Deployment as internal service with no external exposure - Extracted tickers.go from acb-api to new cmd/acb-matchmaker/ - Tickers: bot pairing (1 min), health checking (15 min), stale job reaping (5 min) - Alerting webhooks moved from acb-api to acb-matchmaker - Created Dockerfile for acb-matchmaker container - Created K8s deployment manifest (no service needed - internal only) - Fixed syntax error in cmd/acb-api/db.go (prematurely closed schemaSQL string) This separates concerns per the plan: - acb-api: HTTP endpoints for bot registration, job coordination, bot status - acb-matchmaker: Internal tickers for matchmaking, health checks, reaping Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1,005 B
Go
36 lines
1,005 B
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
type Server struct {
|
|
cfg Config
|
|
db *sql.DB
|
|
rdb *redis.Client
|
|
// Note: alerter removed - alerting now handled by acb-matchmaker deployment
|
|
}
|
|
|
|
func (s *Server) RegisterRoutes(mux *http.ServeMux) {
|
|
mux.HandleFunc("GET /health", s.handleHealth)
|
|
mux.HandleFunc("GET /ready", s.handleReady)
|
|
mux.HandleFunc("POST /api/register", s.handleRegister)
|
|
mux.HandleFunc("POST /api/rotate-key", s.handleRotateKey)
|
|
mux.HandleFunc("GET /api/status/{bot_id}", s.handleBotStatus)
|
|
mux.HandleFunc("POST /api/jobs/claim", s.handleJobClaim)
|
|
mux.HandleFunc("POST /api/jobs/{job_id}/result", s.handleJobResult)
|
|
}
|
|
|
|
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})
|
|
}
|