fix dynamic subscription, grab hosts from DB (always empty for now)

This commit is contained in:
Charlotte Som 2024-11-27 04:35:35 +02:00
parent d7bfb8feea
commit a3699c4377
2 changed files with 13 additions and 6 deletions

View file

@ -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::<Vec<String>>(&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

View file

@ -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())?)
}