feat: introduce self when bootstrapping

This commit is contained in:
Aravinth Manivannan 2023-02-28 17:30:25 +05:30
parent 2c4344a23f
commit 8564f40478
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
4 changed files with 14 additions and 1 deletions

View file

@ -39,6 +39,7 @@ wait_before_next_api_call = 2 # in seconds
[introducer]
#nodes = ["http://localhost:7000"]
public_url = "http://localhost:7000"
nodes = []
[repository]

View file

@ -44,7 +44,6 @@ pub async fn lastest(federate: WebFederate) -> ServiceResult<impl Responder> {
Ok(HttpResponse::Ok().json(latest))
}
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(lastest);
cfg.service(forges);

View file

@ -50,6 +50,18 @@ impl Ctx {
.json()
.await
.unwrap();
let mut introduce_url = starchart.clone();
introduce_url.set_path(ROUTES.introducer.introduce);
let introduction_payload = Starchart {
instance_url: self.settings.introducer.public_url.to_string(),
};
self.client
.post(introduce_url)
.json(&introduction_payload)
.send()
.await
.unwrap();
if nodes.is_empty() {
break;
}

View file

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