Skip to content

Commit

Permalink
helath endpoint for execute service
Browse files Browse the repository at this point in the history
  • Loading branch information
jaketarnow committed Jul 11, 2024
1 parent fb71e1c commit 4a15927
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 8 additions & 3 deletions execute-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use execute_service::*;

use snarkvm::prelude::{CanaryV0, MainnetV0, Network, TestnetV0};
use structopt::StructOpt;
use warp::reply::with::headers;
use warp::Filter;

#[derive(StructOpt, Debug)]
Expand All @@ -31,9 +32,13 @@ struct Opt {
async fn run<N: Network>(port: u16) {
pretty_env_logger::init();

let routes = execute_route::<N>().with(warp::trace(
|info| tracing::debug_span!("Debugging headers", headers = ?info.request_headers()),
));
let routes = execute_route::<N>()
.with(warp::trace(
|info| tracing::debug_span!("Debugging headers", headers = ?info.request_headers()),
))
.or(health_route().with(warp::trace(
|info| tracing::debug_span!("Debugging headers", headers = ?info.request_headers()),
)));

warp::serve(routes).run(([127, 0, 0, 1], port)).await;
}
Expand Down
10 changes: 10 additions & 0 deletions execute-service/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ pub fn execute_route<N: Network>() -> impl Filter<Extract = impl Reply, Error =
Ok(response)
})
}

// GET /health
pub fn health_route(
) -> impl Filter<Extract = (warp::reply::WithStatus<&'static str>,), Error = warp::Rejection> + Clone
{
warp::get()
.and(warp::path("health"))
.and(warp::path::end())
.map(|| warp::reply::with_status("Execute Service is up", warp::http::StatusCode::OK))
}

0 comments on commit 4a15927

Please sign in to comment.