Skip to content

Commit 9a10e3e

Browse files
committed
Merge torrust#1413: health_check: service type
99aa259 health_check: service_type field (nuts_rice) Pull request description: addresses torrust#1409 by introducing a `service_type` field for `ServiceHealthCheckJob` displays when accessing /health_check endpoint ACKs for top commit: da2ce7: utACK 99aa259 josecelano: ACK 99aa259 Tree-SHA512: 00331da6889b806a123a69e0293e4beb1675127473218d16f3fd1f5bf64b2f6eae25ef4ae720ebd829ed936338f3b01f84acb74c2157dbac330fd42ff20f9e61
2 parents f71f0c4 + 99aa259 commit 9a10e3e

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

packages/axum-health-check-api-server/src/handlers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub(crate) async fn health_check_handler(State(register): State<ServiceRegistry>
3333
CheckReport {
3434
binding: c.binding,
3535
info: c.info.clone(),
36+
service_type: c.service_type,
3637
result: c.job.await.expect("it should be able to join into the checking function"),
3738
}
3839
})

packages/axum-health-check-api-server/src/resources.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub enum Status {
1212
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
1313
pub struct CheckReport {
1414
pub binding: SocketAddr,
15+
pub service_type: String,
1516
pub info: String,
1617
pub result: Result<String, String>,
1718
}

packages/axum-http-tracker-server/src/server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use tracing::instrument;
1818
use super::v1::routes::router;
1919
use crate::HTTP_TRACKER_LOG_TARGET;
2020

21+
const TYPE_STRING: &str = "http_tracker";
2122
/// Error that can occur when starting or stopping the HTTP server.
2223
///
2324
/// Some errors triggered while starting the server are:
@@ -231,7 +232,7 @@ pub fn check_fn(binding: &SocketAddr) -> ServiceHealthCheckJob {
231232
}
232233
});
233234

234-
ServiceHealthCheckJob::new(*binding, info, job)
235+
ServiceHealthCheckJob::new(*binding, info, TYPE_STRING.to_string(), job)
235236
}
236237

237238
#[cfg(test)]

packages/axum-rest-tracker-api-server/src/server.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ use tracing::{instrument, Level};
4545
use super::routes::router;
4646
use crate::API_LOG_TARGET;
4747

48+
const TYPE_STRING: &str = "tracker_rest_api";
49+
4850
/// Errors that can occur when starting or stopping the API server.
4951
#[derive(Debug, Error)]
5052
pub enum Error {
@@ -204,7 +206,7 @@ pub fn check_fn(binding: &SocketAddr) -> ServiceHealthCheckJob {
204206
Err(err) => Err(err.to_string()),
205207
}
206208
});
207-
ServiceHealthCheckJob::new(*binding, info, job)
209+
ServiceHealthCheckJob::new(*binding, info, TYPE_STRING.to_string(), job)
208210
}
209211

210212
/// A struct responsible for starting the API server.

packages/server-lib/src/registar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub type ServiceHeathCheckResult = Result<String, String>;
1818
pub struct ServiceHealthCheckJob {
1919
pub binding: SocketAddr,
2020
pub info: String,
21+
pub service_type: String,
2122
pub job: JoinHandle<ServiceHeathCheckResult>,
2223
}
2324

packages/udp-tracker-server/src/server/launcher.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::server::receiver::Receiver;
2424

2525
const IP_BANS_RESET_INTERVAL_IN_SECS: u64 = 3600;
2626

27+
const TYPE_STRING: &str = "udp_tracker";
2728
/// A UDP server instance launcher.
2829
#[derive(Constructor)]
2930
pub struct Launcher;
@@ -117,7 +118,7 @@ impl Launcher {
117118

118119
let job = tokio::spawn(async move { check(&binding).await });
119120

120-
ServiceHealthCheckJob::new(binding, info, job)
121+
ServiceHealthCheckJob::new(binding, info, TYPE_STRING.to_string(), job)
121122
}
122123

123124
#[instrument(skip(receiver, udp_tracker_core_container, udp_tracker_server_container))]

0 commit comments

Comments
 (0)