Skip to content

Commit

Permalink
feat:fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <[email protected]>
  • Loading branch information
GrapeBaBa committed Aug 14, 2024
1 parent 028b889 commit 966af5d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bin/archiver/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ use warp::http::{HeaderValue, StatusCode};
use warp::hyper::Body;
use warp::{Filter, Rejection, Reply};

#[allow(dead_code)]
pub struct Api {
archiver: Arc<Archiver>,
}

#[allow(dead_code)]
#[derive(Serialize)]
struct RearchiveResponse {
success: bool,
Expand All @@ -30,12 +32,14 @@ impl Reply for RearchiveResponse {
}

impl Api {
#[allow(dead_code)]
pub fn new(archiver: Archiver) -> Self {
Self {
archiver: Arc::new(archiver),
}
}

#[allow(dead_code)]
pub fn routes(&self) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
let archiver = self.archiver.clone();
warp::path!("rearchive")
Expand All @@ -49,12 +53,14 @@ impl Api {
.and_then(Self::healthz))
}

#[allow(dead_code)]
async fn healthz() -> Result<impl Reply, Rejection> {
Ok(warp::reply::json(&serde_json::json!({
"status": "ok"
})))
}

#[allow(dead_code)]
async fn rearchive_range(
query: RearchiveQuery,
archiver: Arc<Archiver>,
Expand Down Expand Up @@ -112,7 +118,10 @@ impl Api {

#[derive(serde::Deserialize)]
struct RearchiveQuery {
#[allow(dead_code)]
from: Option<u64>,

#[allow(dead_code)]
to: Option<u64>,
}

Expand Down Expand Up @@ -180,9 +189,9 @@ mod tests {
}

#[tokio::test]
async fn test_rearchive_range() {
async fn test_api_rearchive_range() {
let (_, rx) = tokio::sync::watch::channel(false);
let dir = &PathBuf::from("test_rearchive_range");
let dir = &PathBuf::from("test_api_rearchive_range");
let storage = FSStorage::new(dir.clone()).await.unwrap();
tokio::fs::create_dir_all(dir).await.unwrap();
let test_storage = Arc::new(Mutex::new(TestFSStorage::new(storage).await.unwrap()));
Expand Down

0 comments on commit 966af5d

Please sign in to comment.