cat_gateway/service/api/health/mod.rs
1//! Health Endpoints
2use poem_openapi::{OpenApi, param::Query};
3
4use crate::service::common::{
5 auth::{api_key::InternalApiKeyAuthorization, none::NoAuthorization},
6 tags::ApiTags,
7};
8
9mod inspection_get;
10pub(crate) mod live_get;
11pub(crate) mod ready_get;
12pub(crate) mod started_get;
13
14/// Health API Endpoints
15pub(crate) struct HealthApi;
16
17#[OpenApi(tag = "ApiTags::Health")]
18impl HealthApi {
19 /// Service Started
20 ///
21 /// This endpoint is used to determine if the service has started properly
22 /// and is able to serve requests.
23 ///
24 /// ## Note
25 ///
26 /// *This endpoint is for internal use of the service deployment infrastructure.
27 /// It may not be exposed publicly.*
28 #[oai(
29 path = "/v1/health/started",
30 method = "get",
31 operation_id = "healthStarted"
32 )]
33 #[allow(clippy::unused_async)]
34 async fn started_get(
35 &self,
36 _auth: NoAuthorization,
37 ) -> started_get::AllResponses {
38 started_get::endpoint()
39 }
40
41 /// Service Ready
42 ///
43 /// This endpoint is used to determine if the service is ready and able to serve
44 /// requests.
45 ///
46 /// ## Note
47 ///
48 /// *This endpoint is for internal use of the service deployment infrastructure.
49 /// It may not be exposed publicly.*
50 #[oai(
51 path = "/v1/health/ready",
52 method = "get",
53 operation_id = "healthReady"
54 )]
55 #[allow(clippy::unused_async)]
56 async fn ready_get(
57 &self,
58 _auth: NoAuthorization,
59 ) -> ready_get::AllResponses {
60 ready_get::endpoint()
61 }
62
63 /// Service Live
64 ///
65 /// This endpoint is used to determine if the service is live.
66 ///
67 /// ## Note
68 ///
69 /// *This endpoint is for internal use of the service deployment infrastructure.
70 /// It may not be exposed publicly. Refer to []*
71 #[oai(path = "/v1/health/live", method = "get", operation_id = "healthLive")]
72 #[allow(clippy::unused_async)]
73 async fn live_get(
74 &self,
75 _auth: NoAuthorization,
76 ) -> live_get::AllResponses {
77 live_get::endpoint()
78 }
79
80 /// Service Inspection Control.
81 ///
82 /// This endpoint is used to control internal service inspection features.
83 ///
84 /// ## Note
85 ///
86 /// *This endpoint is for internal use of the service deployment infrastructure.
87 /// It may not be exposed publicly.*
88 // TODO: Make the parameters to this a JSON Body, not query parameters.
89 #[oai(
90 path = "/v1/health/inspection",
91 method = "put",
92 operation_id = "healthInspection",
93 hidden = true
94 )]
95 async fn inspection(
96 &self,
97 /// The log level to use for the service. Controls what detail gets logged.
98 log_level: Query<Option<inspection_get::LogLevel>>,
99 /// Enable or disable Verbose Query inspection in the logs. Used to find query
100 /// performance issues.
101 query_inspection: Query<Option<inspection_get::DeepQueryInspectionFlag>>,
102 _auth: InternalApiKeyAuthorization,
103 ) -> inspection_get::AllResponses {
104 inspection_get::endpoint(log_level.0, query_inspection.0).await
105 }
106}