feat: sleep in between introductions

This commit is contained in:
Aravinth Manivannan 2023-03-25 21:29:56 +05:30
parent 1ebb18b884
commit 1a121139e3
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
3 changed files with 9 additions and 1 deletions

View file

@ -41,6 +41,7 @@ wait_before_next_api_call = 2 # in seconds
#nodes = ["http://localhost:7000"]
public_url = "http://localhost:7000"
nodes = []
wait=1
[repository]
root = "/tmp/starchart.forgeflux.org"

View file

@ -18,6 +18,7 @@
use std::collections::HashSet;
use std::future::Future;
use actix::clock::sleep;
use actix_web::web;
use actix_web::{HttpResponse, Responder};
use actix_web_codegen_const_routes::get;
@ -150,7 +151,7 @@ impl Ctx {
let shutdown = match rx.try_recv() {
// The channel is currently empty
Ok(x) => {
log::info!("Received signal from tx");
log::info!("[introducer] Received signal {x}");
x
}
Err(TryRecvError::Empty) => false,
@ -164,6 +165,11 @@ impl Ctx {
}
let _ = ctx.bootstrap(&db).await;
log::info!(
"Waiting for {} until re-introducing",
ctx.settings.introducer.wait
);
tokio::time::sleep(std::time::Duration::new(ctx.settings.introducer.wait, 0)).await;
}
};

View file

@ -134,6 +134,7 @@ pub struct Crawler {
pub struct Introducer {
pub nodes: Vec<Url>,
pub public_url: Url,
pub wait: u64,
}
#[derive(Debug, Validate, Clone, PartialEq, Eq, Serialize, Deserialize)]