feat: import index from federating node
This commit is contained in:
parent
7b3bc8161e
commit
359c0133b8
2 changed files with 20 additions and 0 deletions
|
@ -19,6 +19,10 @@ async-trait = "0.1.51"
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
serde = { version = "1", features = ["derive"]}
|
serde = { version = "1", features = ["derive"]}
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
|
api_routes = { path = "../../api_routes/" }
|
||||||
|
|
||||||
|
[dependencies.reqwest]
|
||||||
|
version = "0.11.10"
|
||||||
|
|
||||||
[dependencies.db-core]
|
[dependencies.db-core]
|
||||||
path = "../../db/db-core"
|
path = "../../db/db-core"
|
||||||
|
|
|
@ -20,6 +20,7 @@ use std::path::PathBuf;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use reqwest::Client;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use db_core::prelude::*;
|
use db_core::prelude::*;
|
||||||
|
@ -27,6 +28,8 @@ use db_core::prelude::*;
|
||||||
#[cfg(feature = "test")]
|
#[cfg(feature = "test")]
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
|
|
||||||
|
pub use api_routes::*;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Federate: Sync + Send {
|
pub trait Federate: Sync + Send {
|
||||||
type Error: std::error::Error + std::fmt::Debug;
|
type Error: std::error::Error + std::fmt::Debug;
|
||||||
|
@ -79,6 +82,19 @@ pub trait Federate: Sync + Send {
|
||||||
|
|
||||||
/// get latest tar ball
|
/// get latest tar ball
|
||||||
async fn latest_tar(&self) -> Result<String, Self::Error>;
|
async fn latest_tar(&self) -> Result<String, Self::Error>;
|
||||||
|
|
||||||
|
/// import archive from another Starchart instance
|
||||||
|
async fn import(
|
||||||
|
&self,
|
||||||
|
mut starchart_url: Url,
|
||||||
|
client: &Client,
|
||||||
|
db: &Box<dyn SCDatabase>,
|
||||||
|
) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
|
async fn latest_tar_json(&self) -> Result<LatestResp, Self::Error> {
|
||||||
|
let latest = self.latest_tar().await?;
|
||||||
|
Ok(LatestResp { latest })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_hostname(url: &Url) -> &str {
|
pub fn get_hostname(url: &Url) -> &str {
|
||||||
|
|
Loading…
Reference in a new issue