fix dynamic subscription, grab hosts from DB (always empty for now)
This commit is contained in:
parent
d7bfb8feea
commit
a3699c4377
2 changed files with 13 additions and 6 deletions
13
src/main.rs
13
src/main.rs
|
@ -29,11 +29,14 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let server = Arc::new(RelayServer::new(db, event_tx));
|
let server = Arc::new(RelayServer::new(db, event_tx));
|
||||||
|
|
||||||
// TODO: load host list from db
|
let hosts = server
|
||||||
index_servers(
|
.db
|
||||||
Arc::clone(&server),
|
.get("hosts")?
|
||||||
&["pds.bun.how".into(), "pds-testing.bun.how".into()],
|
.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);
|
start_sequencer(Arc::clone(&server), event_rx);
|
||||||
|
|
||||||
// TODO: configurable bind address
|
// TODO: configurable bind address
|
||||||
|
|
|
@ -28,7 +28,11 @@ pub async fn handle_request_crawl(
|
||||||
};
|
};
|
||||||
|
|
||||||
let hostname = input.data.hostname;
|
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())?)
|
Ok(Response::builder().status(200).body(body_empty())?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue