Skip to content

Commit d32284a

Browse files
committed
Return HealthCheckResponse with protocol version from /vss/health
1 parent b605fad commit d32284a

4 files changed

Lines changed: 47 additions & 6 deletions

File tree

proto/vss.proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,22 @@ message ListKeyVersionsResponse {
245245
optional int64 global_version = 3;
246246
}
247247

248+
// Request payload to be used for `HealthCheck` API call to server.
249+
// Clients can call this API to verify that the server is running and to query
250+
// the version of the VSS protocol supported by the server.
251+
// This API is unauthenticated.
252+
message HealthCheckRequest {
253+
}
254+
255+
// Server response for `HealthCheck` API.
256+
// A successful HTTP 200 response indicates that the VSS server is operational.
257+
message HealthCheckResponse {
258+
259+
// The version of the VSS protocol supported by this server.
260+
// Clients can use this to verify protocol compatibility with the server.
261+
int64 version = 1;
262+
}
263+
248264
// When HttpStatusCode is not ok (200), the response `content` contains a serialized `ErrorResponse`
249265
// with the relevant `ErrorCode` and `message`
250266
message ErrorResponse {

rust/api/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#![deny(rustdoc::private_intra_doc_links)]
1010
#![deny(missing_docs)]
1111

12+
/// The version of the VSS protocol supported by this implementation.
13+
/// Returned to clients via the `HealthCheck` API for protocol compatibility checks.
14+
pub const VSS_PROTOCOL_VERSION: i64 = 1;
15+
1216
/// Contains interface for authorizer that is run before every request, and its corresponding implementations.
1317
pub mod auth;
1418
/// Implements the error type ([`error::VssError`]) which is eventually converted to [`ErrorResponse`] and returned to the client.

rust/api/src/types.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,23 @@ pub struct ListKeyVersionsResponse {
247247
#[prost(int64, optional, tag = "3")]
248248
pub global_version: ::core::option::Option<i64>,
249249
}
250+
/// Request payload to be used for `HealthCheck` API call to server.
251+
/// Clients can call this API to verify that the server is running and to query
252+
/// the version of the VSS protocol supported by the server.
253+
/// This API is unauthenticated.
254+
#[allow(clippy::derive_partial_eq_without_eq)]
255+
#[derive(Clone, PartialEq, ::prost::Message)]
256+
pub struct HealthCheckRequest {}
257+
/// Server response for `HealthCheck` API.
258+
/// A successful HTTP 200 response indicates that the VSS server is operational.
259+
#[allow(clippy::derive_partial_eq_without_eq)]
260+
#[derive(Clone, PartialEq, ::prost::Message)]
261+
pub struct HealthCheckResponse {
262+
/// The version of the VSS protocol supported by this server.
263+
/// Clients can use this to verify protocol compatibility with the server.
264+
#[prost(int64, tag = "1")]
265+
pub version: i64,
266+
}
250267
/// When HttpStatusCode is not ok (200), the response `content` contains a serialized `ErrorResponse`
251268
/// with the relevant `ErrorCode` and `message`
252269
#[allow(clippy::derive_partial_eq_without_eq)]

rust/server/src/vss_service.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ use api::error::VssError;
1111
use api::kv_store::KvStore;
1212
use api::types::{
1313
DeleteObjectRequest, DeleteObjectResponse, ErrorCode, ErrorResponse, GetObjectRequest,
14-
GetObjectResponse, ListKeyVersionsRequest, ListKeyVersionsResponse, PutObjectRequest,
15-
PutObjectResponse,
14+
GetObjectResponse, HealthCheckResponse, ListKeyVersionsRequest, ListKeyVersionsResponse,
15+
PutObjectRequest, PutObjectResponse,
1616
};
17+
use api::VSS_PROTOCOL_VERSION;
1718
use std::future::Future;
1819
use std::pin::Pin;
1920
use std::sync::Arc;
@@ -80,10 +81,13 @@ impl Service<Request<Incoming>> for VssService {
8081
let prefix_stripped_path = path.strip_prefix(BASE_PATH_PREFIX).unwrap_or_default();
8182

8283
match prefix_stripped_path {
83-
"/health" => Ok(Response::builder()
84-
.status(StatusCode::OK)
85-
.body(Full::new(Bytes::new()))
86-
.unwrap()),
84+
"/health" => {
85+
let response = HealthCheckResponse { version: VSS_PROTOCOL_VERSION };
86+
Ok(Response::builder()
87+
.status(StatusCode::OK)
88+
.body(Full::new(Bytes::from(response.encode_to_vec())))
89+
.unwrap())
90+
},
8791
"/getObject" => {
8892
handle_request(
8993
store,

0 commit comments

Comments
 (0)