feat: sleep in between introductions
This commit is contained in:
parent
1ebb18b884
commit
1a121139e3
3 changed files with 9 additions and 1 deletions
|
@ -41,6 +41,7 @@ wait_before_next_api_call = 2 # in seconds
|
||||||
#nodes = ["http://localhost:7000"]
|
#nodes = ["http://localhost:7000"]
|
||||||
public_url = "http://localhost:7000"
|
public_url = "http://localhost:7000"
|
||||||
nodes = []
|
nodes = []
|
||||||
|
wait=1
|
||||||
|
|
||||||
[repository]
|
[repository]
|
||||||
root = "/tmp/starchart.forgeflux.org"
|
root = "/tmp/starchart.forgeflux.org"
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
|
use actix::clock::sleep;
|
||||||
use actix_web::web;
|
use actix_web::web;
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
use actix_web_codegen_const_routes::get;
|
use actix_web_codegen_const_routes::get;
|
||||||
|
@ -150,7 +151,7 @@ impl Ctx {
|
||||||
let shutdown = match rx.try_recv() {
|
let shutdown = match rx.try_recv() {
|
||||||
// The channel is currently empty
|
// The channel is currently empty
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
log::info!("Received signal from tx");
|
log::info!("[introducer] Received signal {x}");
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
Err(TryRecvError::Empty) => false,
|
Err(TryRecvError::Empty) => false,
|
||||||
|
@ -164,6 +165,11 @@ impl Ctx {
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = ctx.bootstrap(&db).await;
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ pub struct Crawler {
|
||||||
pub struct Introducer {
|
pub struct Introducer {
|
||||||
pub nodes: Vec<Url>,
|
pub nodes: Vec<Url>,
|
||||||
pub public_url: Url,
|
pub public_url: Url,
|
||||||
|
pub wait: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Validate, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Validate, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue