mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 13:27:43 +00:00
fix: blocking forever
Closes #102 Signed-off-by: bestgopher <84328409@qq.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::error::ErrorCode;
|
||||
use crate::Result as LocalResult;
|
||||
use crate::{error::ErrorCode, object_api::ObjectApi};
|
||||
|
||||
use axum::{extract::State, Json};
|
||||
use serde::Serialize;
|
||||
@@ -39,12 +39,17 @@ struct PoolDecommissionInfo {
|
||||
bytes_failed: i64,
|
||||
}
|
||||
|
||||
pub async fn handler(State(ec_store): State<ObjectApi>) -> LocalResult<Json<Vec<PoolStatus>>> {
|
||||
pub async fn handler() -> LocalResult<Json<Vec<PoolStatus>>> {
|
||||
// if ecstore::is_legacy().await {
|
||||
// return Err(ErrorCode::ErrNotImplemented);
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
let pools = (*ec_store).as_ref().ok_or(ErrorCode::ErrNotImplemented)?;
|
||||
// todo 实用oncelock作为全局变量
|
||||
let layer = ecstore::new_object_layer_fn();
|
||||
let lock = layer.read().await;
|
||||
let pools = lock.as_ref().ok_or(ErrorCode::ErrNotImplemented)?;
|
||||
|
||||
// todo, 调用pool.status()接口获取每个池的数据
|
||||
//
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
pub mod error;
|
||||
pub mod handlers;
|
||||
pub mod object_api;
|
||||
|
||||
use axum::{extract::Request, response::Response, routing::get, BoxError, Router};
|
||||
use ecstore::store::ECStore;
|
||||
use error::ErrorCode;
|
||||
use handlers::list_pools;
|
||||
use object_api::ObjectApi;
|
||||
use tower::Service;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, ErrorCode>;
|
||||
|
||||
const API_VERSION: &str = "/v3";
|
||||
|
||||
pub fn register_admin_router(
|
||||
ec_store: Option<ECStore>,
|
||||
) -> impl Service<Request, Response = Response, Error: Into<BoxError>, Future: Send> + Clone {
|
||||
pub fn register_admin_router() -> impl Service<Request, Response = Response, Error: Into<BoxError>, Future: Send> + Clone {
|
||||
Router::new()
|
||||
.nest(
|
||||
"/rustfs/admin",
|
||||
Router::new().nest(API_VERSION, Router::new().route("/pools/list", get(list_pools::handler))),
|
||||
)
|
||||
.with_state::<()>(ObjectApi::new(ec_store))
|
||||
.into_service()
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use ecstore::store::ECStore;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ObjectApi(Option<ECStore>);
|
||||
|
||||
impl Deref for ObjectApi {
|
||||
type Target = Option<ECStore>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectApi {
|
||||
pub fn new(t: Option<ECStore>) -> Self {
|
||||
Self(t)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user