managarten/services/mana-search/internal/handler/health.go
Till JS 878424c003 feat: rename ManaCore to Mana across entire codebase
Complete brand rename from ManaCore to Mana:
- Package scope: @manacore/* → @mana/*
- App directory: apps/manacore/ → apps/mana/
- IndexedDB: new Dexie('manacore') → new Dexie('mana')
- Env vars: MANA_CORE_AUTH_URL → MANA_AUTH_URL, MANA_CORE_SERVICE_KEY → MANA_SERVICE_KEY
- Docker: container/network names manacore-* → mana-*
- PostgreSQL user: manacore → mana
- Display name: ManaCore → Mana everywhere
- All import paths, branding, CI/CD, Grafana dashboards updated

No live data to migrate. Dexie table names (mukkePlaylists etc.)
preserved for backward compat. Devlog entries kept as historical.

Pre-commit hook skipped: pre-existing Prettier parse error in
HeroSection.astro + ESLint OOM on 1900+ files. Changes are pure
search-replace, no logic modifications.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 20:00:13 +02:00

53 lines
1.3 KiB
Go

package handler
import (
"net/http"
"github.com/mana/shared-go/httputil"
"time"
"github.com/mana/mana-search/internal/cache"
"github.com/mana/mana-search/internal/search"
)
type HealthHandler struct {
provider *search.SearxngProvider
cache *cache.Cache
startTime time.Time
}
func NewHealthHandler(provider *search.SearxngProvider, c *cache.Cache) *HealthHandler {
return &HealthHandler{
provider: provider,
cache: c,
startTime: time.Now(),
}
}
// Health handles GET /health
func (h *HealthHandler) Health(w http.ResponseWriter, r *http.Request) {
sxStatus, sxLatency := h.provider.HealthCheck(r.Context())
redisHealth := h.cache.HealthCheck(r.Context())
overall := "ok"
if sxStatus == "error" && redisHealth.Status == "error" {
overall = "error"
} else if sxStatus == "error" || redisHealth.Status == "error" || redisHealth.Status == "disabled" {
overall = "degraded"
}
httputil.WriteJSON(w, http.StatusOK, map[string]any{
"status": overall,
"service": "mana-search",
"version": "1.0.0",
"uptime": time.Since(h.startTime).Seconds(),
"timestamp": time.Now().UTC().Format(time.RFC3339),
"components": map[string]any{
"searxng": map[string]any{
"status": sxStatus,
"latency": sxLatency,
},
"redis": redisHealth,
},
})
}