<% ' ApiHealthController: liveness and readiness probes (spec 9, health). No authentication, no tenant data. ' ' GET /api/v1/health/live Live 200 while the process answers ' GET /api/v1/health/ready Ready 200 when the database answers (status ready, or degraded when the embedding ' provider / vector store is unreachable), else 503 Class ApiHealthController_Class Public Property Get useLayout() useLayout = False End Property Public Property Let useLayout(v) End Property Public Property Get Title() Title = "Health" End Property Public Sub Live() Api_Send 200, "{""status"":""live""}" End Sub ' 503 only when the database is down. Semantic retrieval is optional (lexical keeps working), so an unreachable ' embedding provider or vector store gives 200 with status "degraded". Counts only, no tenant data. Public Sub Ready() Dim rs, ok, emb, store, pending, failed, status, resp, st ok = False pending = 0 failed = 0 On Error Resume Next Set rs = DAL().Query("SELECT 1", Empty) If Err.Number = 0 Then ok = Not rs.EOF rs.Close End If Err.Clear If ok Then Set rs = DAL().Query("SELECT SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END), SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) FROM embedding_index", Empty) If Err.Number = 0 Then If Not rs.EOF Then If Not IsNull(rs(0)) Then pending = CLng(rs(0)) failed = CLng(rs(1)) End If End If rs.Close End If Err.Clear End If On Error GoTo 0 If Not ok Then Api_Send 503, "{""status"":""unavailable"",""checks"":{""database"":""down""}}" Exit Sub End If status = "ready" If Emb_Enabled() Then resp = Emb_Http("GET", Emb_Setting("EmbeddingUrl", "http://ollama:11434") & "/api/version", "", st) If st = 200 Then emb = "up" Else emb = "down" status = "degraded" End If resp = Emb_Http("GET", Emb_Setting("VectorStoreUrl", "http://qdrant:6333") & "/readyz", "", st) If st = 200 Then store = "up" Else store = "down" status = "degraded" End If Else emb = "disabled" store = "disabled" End If Api_Send 200, "{""status"":""" & status & """,""checks"":{""database"":""up"",""embeddings"":""" & emb & """,""vector_store"":""" & store & """}" & _ ",""embedding_backlog"":{""pending"":" & pending & ",""failed"":" & failed & "}}" End Sub ' Static action dispatch (AxonASP mishandles runtime-built Eval/Execute calls and shared call sites) Public Sub Invoke(actionName, args) Select Case LCase(actionName) Case "live" : Live Case "ready" : Ready Case Else Err.Raise 438, "ApiHealthController_Class", "Action '" & actionName & "' not found" End Select End Sub End Class Dim ApiHealthController_Class__Singleton Function ApiHealthController() If IsEmpty(ApiHealthController_Class__Singleton) Then Set ApiHealthController_Class__Singleton = New ApiHealthController_Class End If Set ApiHealthController = ApiHealthController_Class__Singleton End Function ' Global entry point used by MVC_InvokeAction via GetRef (one call site per controller) Sub ApiHealthController_Invoke(actionName, args) ApiHealthController().Invoke actionName, args End Sub %>