···1111use std::env;
12121313pub const DB_MAX_REQ: usize = 65535;
1414+pub const MAX_RECONNECT_ATTEMPTS: usize = 30;
14151516mod config_value;
1617···8081 resolver
8182 .pds_for_did(&self::USER_DID)
8283 .await
8383- .expect("The did document for a user should contain a #atproto_pds service with a url")
8484+ .expect(
8585+ "The did document for a user should contain a #atproto_pds service with a url",
8686+ )
8487 .domain()
8588 .expect("A users pds should have a domain.")
8689 .to_string()
+18-9
src/ingest/queue.rs
···4747 // if it failed, try reconnect 10 times, waiting a second between each attempt
4848 Err(_) => {
4949 let mut new_messages = None;
5050- for _ in 0..10 {
5151- let Ok(stream) =
5252- client.subscribe(&SubscribeRepos::new().build()).await
5353- else {
5454- // wait a second
5555- thread::sleep(Duration::from_secs(1));
5656- continue;
5757- };
5858- new_messages = Some(stream.into_stream().1)
5050+ for i in 0..config::MAX_RECONNECT_ATTEMPTS {
5151+ new_messages = match client
5252+ .subscribe(&SubscribeRepos::new().build())
5353+ .await
5454+ {
5555+ Ok(val) => Some(val.into_stream().1),
5656+ Err(err) => {
5757+ eprintln!(
5858+ "Warning: Error: {} ({}/{})",
5959+ err,
6060+ i + 1,
6161+ config::MAX_RECONNECT_ATTEMPTS
6262+ );
6363+ thread::sleep(Duration::from_secs(1));
6464+ continue;
6565+ }
6666+ }
5967 }
60686169 if let Some(new_messages) = new_messages {
7070+ println!("Reconnected.");
6271 new_messages
6372 } else {
6473 // could not reconnect so just die lmao