Skip to content

Commit

Permalink
feat: wip healthcheck service for paths
Browse files Browse the repository at this point in the history
  • Loading branch information
junkurihara committed Oct 27, 2023
1 parent 135a0e3 commit a5f3d79
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
34 changes: 34 additions & 0 deletions dap-lib/src/doh_client/doh_client_healthcheck.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use super::DoHClient;
use crate::{error::*, log::*};
use std::sync::Arc;
use tokio::sync::Notify;

impl DoHClient {
/// Start health check service
pub async fn start_healthcheck_service(&self, term_notify: Option<Arc<Notify>>) -> Result<()> {
info!("Start periodic path health check service with cache purge");
match term_notify {
Some(term) => {
tokio::select! {
_ = self.healthcheck_service() => {
warn!("Health check service got down.");
}
_ = term.notified() => {
info!("Health check service receives term signal");
}
}
}
None => {
self.healthcheck_service().await?;
warn!("Health check service got down.");
}
}
Ok(())
}

/// Health check service periodically checks the health of the path and purge the cache
async fn healthcheck_service(&self) -> Result<()> {
//TODO:
Ok(())
}
}
4 changes: 1 addition & 3 deletions dap-lib/src/doh_client/doh_client_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ impl DoHClient {
// cache
let cache = Arc::new(Cache::new(globals.proxy_config.max_cache_size));

// TODO: 3. spawn healthcheck for every possible path? too many?
// TODO: 4. cache purge service, simultaneously with healthcheck?
// TODO: 5. implement query plugins
Ok(Self {
http_client,
auth_client,
Expand All @@ -128,6 +125,7 @@ impl DoHClient {
DapError::InvalidDnsQuery
})?;

//TODO:TODO:TODO:!
// // Process query plugins, e.g., domain filtering, cloaking, etc.
// if let Some(query_plugins) = context.query_plugins.clone() {
// let execution_result = query_plugins.execute(&query_msg, &req.0[0], context.min_ttl)?;
Expand Down
4 changes: 4 additions & 0 deletions dap-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ pub async fn entrypoint(
// build doh_client
let doh_client = Arc::new(DoHClient::new(globals.clone(), http_client.inner(), authenticator).await?);

// TODO: 3. spawn healthcheck for every possible path? too many?
// TODO: 4. cache purge service, simultaneously with healthcheck?
// TODO: 5. implement query plugins

// spawn endpoint ip update service with bootstrap dns resolver and doh_client
let doh_client_clone = doh_client.clone();
let term_notify_clone = term_notify;
Expand Down

0 comments on commit a5f3d79

Please sign in to comment.