feat(health-checks): enhance health check functionality and add new routes
quality / commitlint (push) Skipped
CD / update-wiki (push) Failing after 8s
quality / changes (push) Successful in 5s
quality / docker-check (push) Skipped
quality / web (push) Successful in 50s
quality / api (push) Successful in 41s
CD / quality (push) Successful in 1m40s
CD / publish (push) Successful in 1m33s

- Introduced origin health check routes and integrated them into the application.
- Updated health check configuration to include success recovery thresholds.
- Expanded error handling with new error codes for health check failures.
- Added new service routes for managing health checks, including creation and listing.
- Improved health check service logic to track consecutive successes and failures.

This commit enhances the health check capabilities, providing better monitoring and management of service health.
This commit is contained in:
Denozordec committed 2026-08-19 12:26:12 +07:00
1 parent 9c00b268dc
commit 3f6f402872
64 files changed
+6356 -360

No files matched your search

+89
View File
@@ -83,3 +83,92 @@ export async function createServiceBinding(body: CreateServiceBindingBody) {
export async function deleteServiceBinding(id: number) {
return api.delete<{ deleted: boolean }>(`/api/v1/service-bindings/${id}`)
}
export const serviceDetailKeys = {
overview: (id: number) => [...serviceKeys.all, id, 'overview'] as const,
nodes: (id: number) => [...serviceKeys.all, id, 'nodes'] as const,
}
export const serviceOverviewQueryOptions = (id: number) =>
queryOptions({
queryKey: serviceDetailKeys.overview(id),
queryFn: () => api.get(`/api/v1/services/${id}/overview`),
})
export const serviceNodesQueryOptions = (id: number) =>
queryOptions({
queryKey: serviceDetailKeys.nodes(id),
queryFn: () => api.get(`/api/v1/services/${id}/nodes`),
})
export const opsSummaryQueryOptions = () =>
queryOptions({
queryKey: ['ops-summary'] as const,
queryFn: () =>
api.get<{
domains: number
services: number
nodes: number
healthy: number
unhealthy: number
active_failovers: number
}>('/api/v1/ops-summary'),
})
export async function createServiceNode(
serviceId: number,
body: {
address: string
protocol?: string
port?: number | null
priority?: number
weight?: number
},
) {
return api.post(`/api/v1/services/${serviceId}/nodes`, body)
}
export async function deleteServiceNode(serviceId: number, nodeId: number) {
return api.delete(`/api/v1/services/${serviceId}/nodes/${nodeId}`)
}
export async function changeBindingIp(
bindingId: number,
body: {
from_ip?: string
to_ip?: string
node_id?: number
dry_run?: boolean
},
) {
return api.post<{
from_ip: string
to_ip: string
applied: boolean
dry_run: boolean
message: string
}>(`/api/v1/service-bindings/${bindingId}/change-ip`, body)
}
export async function changeServiceDomain(
serviceId: number,
body: {
from_domain_id: number
to_domain_id: number
hostnames?: string[]
dry_run?: boolean
},
) {
return api.post<{ message?: string }>(
`/api/v1/services/${serviceId}/change-domain`,
body,
)
}
export async function createOriginHealthCheck(body: Record<string, unknown>) {
return api.post('/api/v1/health-checks', body)
}
export async function listOriginHealthChecks() {
return api.get('/api/v1/health-checks')
}