feat: introduce self when bootstrapping
This commit is contained in:
parent
2c4344a23f
commit
8564f40478
4 changed files with 14 additions and 1 deletions
|
@ -39,6 +39,7 @@ wait_before_next_api_call = 2 # in seconds
|
||||||
|
|
||||||
[introducer]
|
[introducer]
|
||||||
#nodes = ["http://localhost:7000"]
|
#nodes = ["http://localhost:7000"]
|
||||||
|
public_url = "http://localhost:7000"
|
||||||
nodes = []
|
nodes = []
|
||||||
|
|
||||||
[repository]
|
[repository]
|
||||||
|
|
|
@ -44,7 +44,6 @@ pub async fn lastest(federate: WebFederate) -> ServiceResult<impl Responder> {
|
||||||
Ok(HttpResponse::Ok().json(latest))
|
Ok(HttpResponse::Ok().json(latest))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
cfg.service(lastest);
|
cfg.service(lastest);
|
||||||
cfg.service(forges);
|
cfg.service(forges);
|
||||||
|
|
|
@ -50,6 +50,18 @@ impl Ctx {
|
||||||
.json()
|
.json()
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.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() {
|
if nodes.is_empty() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ pub struct Crawler {
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Introducer {
|
pub struct Introducer {
|
||||||
pub nodes: Vec<Url>,
|
pub nodes: Vec<Url>,
|
||||||
|
pub public_url: Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Validate, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Validate, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue