cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
healthz.h
Go to the documentation of this file.
1
9#ifndef __CWIST_HEALTHZ_H__
10#define __CWIST_HEALTHZ_H__
11
12#include <cwist/net/http/http.h>
13#include <stdbool.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* -------------------------------------------------------------------------
20 * Probe types
21 * ---------------------------------------------------------------------- */
22
29
36
39
40/* -------------------------------------------------------------------------
41 * Registry
42 * ---------------------------------------------------------------------- */
43
54bool cwist_healthz_register(const char *name, cwist_health_probe_fn fn, void *ctx);
55
59void cwist_healthz_unregister(const char *name);
60
70void cwist_healthz_run(cwist_health_probe_t *out_probes, size_t max_probes, size_t *out_count,
71 cwist_health_status_t *out_overall);
72
73/* -------------------------------------------------------------------------
74 * HTTP integration
75 * ---------------------------------------------------------------------- */
76
92
100void cwist_app_enable_healthz(struct cwist_app *app);
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* __CWIST_HEALTHZ_H__ */
cwist_health_probe_t(* cwist_health_probe_fn)(void *ctx)
User-provided probe callback.
Definition healthz.h:38
void cwist_healthz_unregister(const char *name)
Unregister a previously registered probe.
Definition healthz.c:88
cwist_health_status
Classification of a subsystem health check.
Definition healthz.h:24
@ CWIST_HEALTH_FAIL
Definition healthz.h:27
@ CWIST_HEALTH_OK
Definition healthz.h:25
@ CWIST_HEALTH_DEGRADED
Definition healthz.h:26
enum cwist_health_status cwist_health_status_t
Classification of a subsystem health check.
bool cwist_healthz_register(const char *name, cwist_health_probe_fn fn, void *ctx)
Register a custom probe function.
Definition healthz.c:45
void cwist_healthz_run(cwist_health_probe_t *out_probes, size_t max_probes, size_t *out_count, cwist_health_status_t *out_overall)
Evaluate all probes and return the aggregate status.
Definition healthz.c:130
void cwist_app_healthz(cwist_http_response *res)
Populate an HTTP response with the healthz JSON payload.
Definition healthz.c:168
void cwist_app_enable_healthz(struct cwist_app *app)
Register built-in health check routes on an application.
Definition app.c:2249
struct cwist_health_probe cwist_health_probe_t
Result of a single probe.
HTTP Protocol Definitions and Helpers.
Main Application Context.
Definition app.h:155
Result of a single probe.
Definition healthz.h:31
const char * name
Definition healthz.h:32
cwist_health_status_t status
Definition healthz.h:33
const char * message
Definition healthz.h:34
HTTP Response Object. Supports standard string body or Zero-Copy pointer body.
Definition http.h:82