Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Apr 8, 2024
1 parent 882b9cf commit d2eed19
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
26 changes: 20 additions & 6 deletions src/meta-srv/src/service/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ pub fn make_admin_service(meta_srv: MetaSrv) -> Admin {
};
let router = router.route("/region-migration", handler);

let router = router
.route("/maintenance", maintenance::MaintenanceHandler {
let router = router.route(
"/maintenance",
maintenance::MaintenanceHandler {
kv_backend: meta_srv.kv_backend().clone(),
});
},
);
let router = Router::nest("/admin", router);

Admin::new(router)
Expand Down Expand Up @@ -302,7 +304,11 @@ mod tests {
let router = Router::nest("/test_root", router);

let res = router
.call("/test_root/test_node", http::Method::GET, HashMap::default())
.call(
"/test_root/test_node",
http::Method::GET,
HashMap::default(),
)
.await
.unwrap();

Expand All @@ -314,7 +320,11 @@ mod tests {
let router = Router::new();

let res = router
.call("/test_root/test_node", http::Method::GET, HashMap::default())
.call(
"/test_root/test_node",
http::Method::GET,
HashMap::default(),
)
.await
.unwrap();

Expand All @@ -328,7 +338,11 @@ mod tests {
let router = Router::nest("/test_root", router);

let res = router
.call("/test_root/test_node", http::Method::GET, HashMap::default())
.call(
"/test_root/test_node",
http::Method::GET,
HashMap::default(),
)
.await
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/meta-srv/src/service/admin/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub struct HeartBeatHandler {
impl HttpHandler for HeartBeatHandler {
async fn handle(
&self,
_: http::Method,
path: &str,
_: http::Method,
params: &HashMap<String, String>,
) -> Result<http::Response<String>> {
if path.ends_with("/help") {
Expand Down
10 changes: 7 additions & 3 deletions src/meta-srv/src/service/admin/maintenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use snafu::{OptionExt, ResultExt};
use tonic::codegen::http;
use tonic::codegen::http::Response;

use crate::error::{InvalidHttpBodySnafu, KvBackendSnafu, MissingRequiredParameterSnafu, ParseBoolSnafu, UnsupportedSnafu};
use crate::error::{
InvalidHttpBodySnafu, KvBackendSnafu, MissingRequiredParameterSnafu, ParseBoolSnafu,
UnsupportedSnafu,
};
use crate::service::admin::HttpHandler;

#[derive(Clone)]
Expand Down Expand Up @@ -89,16 +92,17 @@ impl MaintenanceHandler {
impl HttpHandler for MaintenanceHandler {
async fn handle(
&self,
method: http::Method,
_: &str,
method: http::Method,
params: &HashMap<String, String>,
) -> crate::Result<Response<String>> {
match method {
http::Method::GET => self.get_maintenance().await,
http::Method::PUT => self.set_maintenance(params).await,
_ => UnsupportedSnafu {
operation: format!("http method {method}"),
}.fail()
}
.fail(),
}
}
}

0 comments on commit d2eed19

Please sign in to comment.