Skip to content

Commit

Permalink
Merge pull request #12 from Overmuse/SR/health_check
Browse files Browse the repository at this point in the history
SR/health check
  • Loading branch information
SebRollen authored Oct 15, 2021
2 parents 27a0d61 + c48baaf commit a061b3b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "datastore-server"
version = "0.4.6"
version = "0.5.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
9 changes: 9 additions & 0 deletions server/src/handlers/health.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use super::last::get_last_price;
use crate::redis::Redis;
use warp::Rejection;

#[tracing::instrument(skip(redis))]
pub async fn health_check(redis: Redis) -> Result<impl warp::Reply, Rejection> {
get_last_price("AAPL".to_string(), redis).await?;
Ok(warp::reply())
}
1 change: 1 addition & 0 deletions server/src/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod aggregates;
pub mod dividends;
pub mod health;
pub mod last;
pub mod splits;
19 changes: 19 additions & 0 deletions server/src/routes/health.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::handlers;
use crate::redis::with_redis;
use crate::Redis;
use warp::Filter;

pub fn health_check(
redis: Redis,
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("health_check")
.and(warp::get())
.and(with_redis(redis))
.and_then(handlers::health::health_check)
}

pub fn health_routes(
redis: Redis,
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
health_check(redis)
}
3 changes: 3 additions & 0 deletions server/src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ use warp::Filter;
mod aggregates;
mod backfill;
mod dividends;
mod health;
mod last;
mod splits;
pub use aggregates::*;
pub use backfill::*;
pub use dividends::*;
pub use health::*;
pub use last::*;
pub use splits::*;

Expand All @@ -22,6 +24,7 @@ pub fn routes(
aggregates_routes(db.clone())
.or(backfill_routes(db.clone()))
.or(dividends_routes(db.clone()))
.or(health_routes(redis.clone()))
.or(last_routes(redis))
.or(splits_routes(db))
.recover(handle_rejection)
Expand Down

0 comments on commit a061b3b

Please sign in to comment.