Skip to content

Commit b0d2e78

Browse files
authored
chore: removing /info endpoint in a favor of /health (#291)
1 parent 21ec1ed commit b0d2e78

File tree

5 files changed

+18
-39
lines changed

5 files changed

+18
-39
lines changed

src/handlers/health.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ use {
55
};
66

77
pub async fn handler(ExtractState(state): ExtractState<Arc<AppState>>) -> impl IntoResponse {
8+
let build_commit = match state.build_info.version_control.clone() {
9+
Some(v) => v.git().unwrap().commit_short_id.clone(),
10+
None => String::new(),
11+
};
812
(
913
StatusCode::OK,
10-
format!("OK, echo-server v{}", state.build_info.crate_info.version,),
14+
format!(
15+
"OK v{}, commit hash: {}, features: {:?}, instance id: {}, uptime: {} seconds",
16+
state.build_info.crate_info.version,
17+
build_commit,
18+
state.build_info.crate_info.enabled_features,
19+
state.instance_id,
20+
state.uptime.elapsed().as_secs(),
21+
),
1122
)
1223
}

src/handlers/info.rs

-35
This file was deleted.

src/handlers/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use {
2929

3030
// Push
3131
pub mod delete_client;
32-
pub mod info;
3332
pub mod metrics;
3433
pub mod push_message;
3534
pub mod register_client;

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) ->
235235

236236
let app = Router::new()
237237
.route("/health", get(handlers::health::handler))
238-
.route("/info", get(handlers::info::handler))
239238
.nest("/tenants", tenancy_routes)
240239
.route(
241240
"/:tenant_id/clients",
@@ -263,7 +262,6 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) ->
263262
#[cfg(not(feature = "multitenant"))]
264263
let app = Router::new()
265264
.route("/health", get(handlers::health::handler))
266-
.route("/info", get(handlers::info::handler))
267265
.route(
268266
"/clients",
269267
post(handlers::single_tenant_wrappers::register_handler),

src/state.rs

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ pub struct AppState {
5353
pub public_ip: Option<IpAddr>,
5454
is_multitenant: bool,
5555
pub geoblock: Option<GeoBlockLayer<Arc<MaxMindResolver>>>,
56+
/// Service instance identifier
57+
pub instance_id: uuid::Uuid,
58+
/// Service instance uptime measurement
59+
pub uptime: std::time::Instant,
5660
}
5761

5862
build_info::build_info!(fn build_info);
@@ -100,6 +104,8 @@ pub fn new_state(
100104
public_ip,
101105
is_multitenant,
102106
geoblock: None,
107+
instance_id: uuid::Uuid::new_v4(),
108+
uptime: std::time::Instant::now(),
103109
})
104110
}
105111

0 commit comments

Comments
 (0)