From a3699c4377dd399620e25d07c6f6d4477fe150ce Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Wed, 27 Nov 2024 04:35:35 +0200 Subject: [PATCH] fix dynamic subscription, grab hosts from DB (always empty for now) --- src/main.rs | 13 ++++++++----- src/request_crawl.rs | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index d46c915..c050485 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,11 +29,14 @@ async fn main() -> Result<()> { let server = Arc::new(RelayServer::new(db, event_tx)); - // TODO: load host list from db - index_servers( - Arc::clone(&server), - &["pds.bun.how".into(), "pds-testing.bun.how".into()], - ); + let hosts = server + .db + .get("hosts")? + .and_then(|v| serde_ipld_dagcbor::from_slice::>(&v).ok()) + .unwrap_or_default(); + tracing::debug!(?hosts, "got list of hosts"); + + index_servers(Arc::clone(&server), &hosts); start_sequencer(Arc::clone(&server), event_rx); // TODO: configurable bind address diff --git a/src/request_crawl.rs b/src/request_crawl.rs index 6c16505..7d9678b 100644 --- a/src/request_crawl.rs +++ b/src/request_crawl.rs @@ -28,7 +28,11 @@ pub async fn handle_request_crawl( }; let hostname = input.data.hostname; - index_server(server, hostname).await?; + tokio::task::spawn(async move { + if let Err(e) = index_server(server, hostname).await { + tracing::warn!("encountered error subscribing to PDS: {e:?}"); + } + }); Ok(Response::builder().status(200).body(body_empty())?) }