mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
Merge pull request #476 from rustfs/nugine/feat/grpc-bytes
feat(protos): use `Bytes` for protobuf bytes type fields.
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3581,6 +3581,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
name = "e2e_test"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"common",
|
||||
"ecstore",
|
||||
"flatbuffers 25.2.10",
|
||||
|
||||
@@ -11,15 +11,15 @@ pub struct Error {
|
||||
pub struct PingRequest {
|
||||
#[prost(uint64, tag = "1")]
|
||||
pub version: u64,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub body: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub body: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct PingResponse {
|
||||
#[prost(uint64, tag = "1")]
|
||||
pub version: u64,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub body: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub body: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct HealBucketRequest {
|
||||
@@ -105,8 +105,8 @@ pub struct ReadAllRequest {
|
||||
pub struct ReadAllResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub data: ::prost::bytes::Bytes,
|
||||
#[prost(message, optional, tag = "3")]
|
||||
pub error: ::core::option::Option<Error>,
|
||||
}
|
||||
@@ -119,8 +119,8 @@ pub struct WriteAllRequest {
|
||||
pub volume: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub path: ::prost::alloc::string::String,
|
||||
#[prost(bytes = "vec", tag = "4")]
|
||||
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "4")]
|
||||
pub data: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct WriteAllResponse {
|
||||
@@ -202,8 +202,8 @@ pub struct RenamePartRequest {
|
||||
pub dst_volume: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub dst_path: ::prost::alloc::string::String,
|
||||
#[prost(bytes = "vec", tag = "6")]
|
||||
pub meta: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "6")]
|
||||
pub meta: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct RenamePartResponse {
|
||||
@@ -243,8 +243,8 @@ pub struct WriteRequest {
|
||||
pub path: ::prost::alloc::string::String,
|
||||
#[prost(bool, tag = "4")]
|
||||
pub is_append: bool,
|
||||
#[prost(bytes = "vec", tag = "5")]
|
||||
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "5")]
|
||||
pub data: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct WriteResponse {
|
||||
@@ -271,8 +271,8 @@ pub struct ReadAtRequest {
|
||||
pub struct ReadAtResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub data: ::prost::bytes::Bytes,
|
||||
#[prost(int64, tag = "3")]
|
||||
pub read_size: i64,
|
||||
#[prost(message, optional, tag = "4")]
|
||||
@@ -300,8 +300,8 @@ pub struct WalkDirRequest {
|
||||
/// indicate which one in the disks
|
||||
#[prost(string, tag = "1")]
|
||||
pub disk: ::prost::alloc::string::String,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub walk_dir_options: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub walk_dir_options: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct WalkDirResponse {
|
||||
@@ -633,8 +633,8 @@ pub struct LocalStorageInfoRequest {
|
||||
pub struct LocalStorageInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub storage_info: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub storage_info: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -647,8 +647,8 @@ pub struct ServerInfoRequest {
|
||||
pub struct ServerInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub server_properties: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub server_properties: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -658,8 +658,8 @@ pub struct GetCpusRequest {}
|
||||
pub struct GetCpusResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub cpus: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub cpus: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -669,8 +669,8 @@ pub struct GetNetInfoRequest {}
|
||||
pub struct GetNetInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub net_info: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub net_info: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -680,8 +680,8 @@ pub struct GetPartitionsRequest {}
|
||||
pub struct GetPartitionsResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub partitions: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub partitions: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -691,8 +691,8 @@ pub struct GetOsInfoRequest {}
|
||||
pub struct GetOsInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub os_info: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub os_info: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -702,8 +702,8 @@ pub struct GetSeLinuxInfoRequest {}
|
||||
pub struct GetSeLinuxInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub sys_services: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub sys_services: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -713,8 +713,8 @@ pub struct GetSysConfigRequest {}
|
||||
pub struct GetSysConfigResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub sys_config: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub sys_config: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -724,8 +724,8 @@ pub struct GetSysErrorsRequest {}
|
||||
pub struct GetSysErrorsResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub sys_errors: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub sys_errors: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -735,24 +735,24 @@ pub struct GetMemInfoRequest {}
|
||||
pub struct GetMemInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub mem_info: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub mem_info: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GetMetricsRequest {
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub metric_type: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub opts: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "1")]
|
||||
pub metric_type: ::prost::bytes::Bytes,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub opts: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GetMetricsResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub realtime_metrics: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub realtime_metrics: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -762,8 +762,8 @@ pub struct GetProcInfoRequest {}
|
||||
pub struct GetProcInfoResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub proc_info: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub proc_info: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -786,7 +786,7 @@ pub struct DownloadProfileDataResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(map = "string, bytes", tag = "2")]
|
||||
pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec<u8>>,
|
||||
pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -799,8 +799,8 @@ pub struct GetBucketStatsDataRequest {
|
||||
pub struct GetBucketStatsDataResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub bucket_stats: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub bucket_stats: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -810,8 +810,8 @@ pub struct GetSrMetricsDataRequest {}
|
||||
pub struct GetSrMetricsDataResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub sr_metrics_summary: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub sr_metrics_summary: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -821,8 +821,8 @@ pub struct GetAllBucketStatsRequest {}
|
||||
pub struct GetAllBucketStatsResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub bucket_stats_map: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub bucket_stats_map: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
@@ -979,36 +979,36 @@ pub struct BackgroundHealStatusRequest {}
|
||||
pub struct BackgroundHealStatusResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub bg_heal_state: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub bg_heal_state: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GetMetacacheListingRequest {
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub opts: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "1")]
|
||||
pub opts: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GetMetacacheListingResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub metacache: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub metacache: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct UpdateMetacacheListingRequest {
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub metacache: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "1")]
|
||||
pub metacache: ::prost::bytes::Bytes,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct UpdateMetacacheListingResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub metacache: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes = "bytes", tag = "2")]
|
||||
pub metacache: ::prost::bytes::Bytes,
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ fn main() -> Result<(), AnyError> {
|
||||
// .file_descriptor_set_path(descriptor_set_path)
|
||||
.protoc_arg("--experimental_allow_proto3_optional")
|
||||
.compile_well_known_types(true)
|
||||
.bytes(["."])
|
||||
.emit_rerun_if_changed(false)
|
||||
.compile_protos(proto_files, &[proto_dir.clone()])
|
||||
.map_err(|e| format!("Failed to generate protobuf file: {e}."))?;
|
||||
|
||||
@@ -28,4 +28,5 @@ tower.workspace = true
|
||||
url.workspace = true
|
||||
madmin.workspace =true
|
||||
common.workspace = true
|
||||
rustfs-filemeta.workspace = true
|
||||
rustfs-filemeta.workspace = true
|
||||
bytes.workspace = true
|
||||
|
||||
@@ -43,7 +43,7 @@ async fn ping() -> Result<(), Box<dyn Error>> {
|
||||
// Construct PingRequest
|
||||
let request = Request::new(PingRequest {
|
||||
version: 1,
|
||||
body: finished_data.to_vec(),
|
||||
body: bytes::Bytes::copy_from_slice(finished_data),
|
||||
});
|
||||
|
||||
// Send request and get response
|
||||
@@ -114,7 +114,7 @@ async fn walk_dir() -> Result<(), Box<dyn Error>> {
|
||||
let mut client = node_service_time_out_client(&CLUSTER_ADDR.to_string()).await?;
|
||||
let request = Request::new(WalkDirRequest {
|
||||
disk: "/home/dandan/code/rust/s3-rustfs/target/debug/data".to_string(),
|
||||
walk_dir_options: buf,
|
||||
walk_dir_options: buf.into(),
|
||||
});
|
||||
let mut response = client.walk_dir(request).await?.into_inner();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ async fn is_server_resolvable(endpoint: &Endpoint) -> Result<()> {
|
||||
// 构造 PingRequest
|
||||
let request = Request::new(PingRequest {
|
||||
version: 1,
|
||||
body: finished_data.to_vec(),
|
||||
body: bytes::Bytes::copy_from_slice(finished_data),
|
||||
});
|
||||
|
||||
// 发送请求并获取响应
|
||||
|
||||
@@ -270,7 +270,7 @@ impl DiskAPI for RemoteDisk {
|
||||
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
|
||||
let request = Request::new(WalkDirRequest {
|
||||
disk: self.endpoint.to_string(),
|
||||
walk_dir_options: buf,
|
||||
walk_dir_options: buf.into(),
|
||||
});
|
||||
let mut response = client.walk_dir(request).await?.into_inner();
|
||||
|
||||
@@ -661,7 +661,7 @@ impl DiskAPI for RemoteDisk {
|
||||
src_path: src_path.to_string(),
|
||||
dst_volume: dst_volume.to_string(),
|
||||
dst_path: dst_path.to_string(),
|
||||
meta: meta.to_vec(),
|
||||
meta,
|
||||
});
|
||||
|
||||
let response = client.rename_part(request).await?.into_inner();
|
||||
@@ -783,7 +783,7 @@ impl DiskAPI for RemoteDisk {
|
||||
disk: self.endpoint.to_string(),
|
||||
volume: volume.to_string(),
|
||||
path: path.to_string(),
|
||||
data,
|
||||
data: data.into(),
|
||||
});
|
||||
|
||||
let response = client.write_all(request).await?.into_inner();
|
||||
@@ -813,7 +813,7 @@ impl DiskAPI for RemoteDisk {
|
||||
return Err(response.error.unwrap_or_default().into());
|
||||
}
|
||||
|
||||
Ok(response.data)
|
||||
Ok(response.data.into())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
|
||||
@@ -292,8 +292,8 @@ impl PeerRestClient {
|
||||
let mut buf_o = Vec::new();
|
||||
opts.serialize(&mut Serializer::new(&mut buf_o))?;
|
||||
let request = Request::new(GetMetricsRequest {
|
||||
metric_type: buf_t,
|
||||
opts: buf_o,
|
||||
metric_type: buf_t.into(),
|
||||
opts: buf_o.into(),
|
||||
});
|
||||
|
||||
let response = client.get_metrics(request).await?.into_inner();
|
||||
|
||||
@@ -24,6 +24,7 @@ use lock::{GLOBAL_LOCAL_SERVER, Locker, lock_args::LockArgs};
|
||||
|
||||
use common::globals::GLOBAL_Local_Node_Name;
|
||||
|
||||
use bytes::Bytes;
|
||||
use madmin::health::{
|
||||
get_cpus, get_mem_info, get_os_info, get_partitions, get_proc_info, get_sys_config, get_sys_errors, get_sys_services,
|
||||
};
|
||||
@@ -108,7 +109,7 @@ impl Node for NodeService {
|
||||
|
||||
Ok(tonic::Response::new(PingResponse {
|
||||
version: 1,
|
||||
body: finished_data.to_vec(),
|
||||
body: Bytes::copy_from_slice(finished_data),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -276,19 +277,19 @@ impl Node for NodeService {
|
||||
match disk.read_all(&request.volume, &request.path).await {
|
||||
Ok(data) => Ok(tonic::Response::new(ReadAllResponse {
|
||||
success: true,
|
||||
data: data.to_vec(),
|
||||
data: data.into(),
|
||||
error: None,
|
||||
})),
|
||||
Err(err) => Ok(tonic::Response::new(ReadAllResponse {
|
||||
success: false,
|
||||
data: Vec::new(),
|
||||
data: Bytes::new(),
|
||||
error: Some(err.into()),
|
||||
})),
|
||||
}
|
||||
} else {
|
||||
Ok(tonic::Response::new(ReadAllResponse {
|
||||
success: false,
|
||||
data: Vec::new(),
|
||||
data: Bytes::new(),
|
||||
error: Some(DiskError::other("can not find disk".to_string()).into()),
|
||||
}))
|
||||
}
|
||||
@@ -297,7 +298,7 @@ impl Node for NodeService {
|
||||
async fn write_all(&self, request: Request<WriteAllRequest>) -> Result<Response<WriteAllResponse>, Status> {
|
||||
let request = request.into_inner();
|
||||
if let Some(disk) = self.find_disk(&request.disk).await {
|
||||
match disk.write_all(&request.volume, &request.path, request.data).await {
|
||||
match disk.write_all(&request.volume, &request.path, request.data.into()).await {
|
||||
Ok(_) => Ok(tonic::Response::new(WriteAllResponse {
|
||||
success: true,
|
||||
error: None,
|
||||
@@ -446,7 +447,7 @@ impl Node for NodeService {
|
||||
&request.src_path,
|
||||
&request.dst_volume,
|
||||
&request.dst_path,
|
||||
request.meta.into(),
|
||||
request.meta,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -1577,7 +1578,7 @@ impl Node for NodeService {
|
||||
let Some(store) = new_object_layer_fn() else {
|
||||
return Ok(tonic::Response::new(LocalStorageInfoResponse {
|
||||
success: false,
|
||||
storage_info: vec![],
|
||||
storage_info: Bytes::new(),
|
||||
error_info: Some("errServerNotInitialized".to_string()),
|
||||
}));
|
||||
};
|
||||
@@ -1587,14 +1588,14 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(LocalStorageInfoResponse {
|
||||
success: false,
|
||||
storage_info: vec![],
|
||||
storage_info: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(tonic::Response::new(LocalStorageInfoResponse {
|
||||
success: true,
|
||||
storage_info: buf,
|
||||
storage_info: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1605,13 +1606,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(ServerInfoResponse {
|
||||
success: false,
|
||||
server_properties: vec![],
|
||||
server_properties: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(ServerInfoResponse {
|
||||
success: true,
|
||||
server_properties: buf,
|
||||
server_properties: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1622,13 +1623,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetCpusResponse {
|
||||
success: false,
|
||||
cpus: vec![],
|
||||
cpus: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetCpusResponse {
|
||||
success: true,
|
||||
cpus: buf,
|
||||
cpus: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1640,13 +1641,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetNetInfoResponse {
|
||||
success: false,
|
||||
net_info: vec![],
|
||||
net_info: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetNetInfoResponse {
|
||||
success: true,
|
||||
net_info: buf,
|
||||
net_info: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1657,13 +1658,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = partitions.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetPartitionsResponse {
|
||||
success: false,
|
||||
partitions: vec![],
|
||||
partitions: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetPartitionsResponse {
|
||||
success: true,
|
||||
partitions: buf,
|
||||
partitions: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1674,13 +1675,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = os_info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetOsInfoResponse {
|
||||
success: false,
|
||||
os_info: vec![],
|
||||
os_info: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetOsInfoResponse {
|
||||
success: true,
|
||||
os_info: buf,
|
||||
os_info: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1695,13 +1696,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetSeLinuxInfoResponse {
|
||||
success: false,
|
||||
sys_services: vec![],
|
||||
sys_services: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetSeLinuxInfoResponse {
|
||||
success: true,
|
||||
sys_services: buf,
|
||||
sys_services: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1713,13 +1714,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetSysConfigResponse {
|
||||
success: false,
|
||||
sys_config: vec![],
|
||||
sys_config: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetSysConfigResponse {
|
||||
success: true,
|
||||
sys_config: buf,
|
||||
sys_config: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1731,13 +1732,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetSysErrorsResponse {
|
||||
success: false,
|
||||
sys_errors: vec![],
|
||||
sys_errors: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetSysErrorsResponse {
|
||||
success: true,
|
||||
sys_errors: buf,
|
||||
sys_errors: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1749,13 +1750,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetMemInfoResponse {
|
||||
success: false,
|
||||
mem_info: vec![],
|
||||
mem_info: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetMemInfoResponse {
|
||||
success: true,
|
||||
mem_info: buf,
|
||||
mem_info: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1774,13 +1775,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetMetricsResponse {
|
||||
success: false,
|
||||
realtime_metrics: vec![],
|
||||
realtime_metrics: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetMetricsResponse {
|
||||
success: true,
|
||||
realtime_metrics: buf,
|
||||
realtime_metrics: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -1792,13 +1793,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(GetProcInfoResponse {
|
||||
success: false,
|
||||
proc_info: vec![],
|
||||
proc_info: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(GetProcInfoResponse {
|
||||
success: true,
|
||||
proc_info: buf,
|
||||
proc_info: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -2085,7 +2086,7 @@ impl Node for NodeService {
|
||||
if !ok {
|
||||
return Ok(tonic::Response::new(BackgroundHealStatusResponse {
|
||||
success: false,
|
||||
bg_heal_state: vec![],
|
||||
bg_heal_state: Bytes::new(),
|
||||
error_info: Some("errServerNotInitialized".to_string()),
|
||||
}));
|
||||
}
|
||||
@@ -2094,13 +2095,13 @@ impl Node for NodeService {
|
||||
if let Err(err) = state.serialize(&mut Serializer::new(&mut buf)) {
|
||||
return Ok(tonic::Response::new(BackgroundHealStatusResponse {
|
||||
success: false,
|
||||
bg_heal_state: vec![],
|
||||
bg_heal_state: Bytes::new(),
|
||||
error_info: Some(err.to_string()),
|
||||
}));
|
||||
}
|
||||
Ok(tonic::Response::new(BackgroundHealStatusResponse {
|
||||
success: true,
|
||||
bg_heal_state: buf,
|
||||
bg_heal_state: buf.into(),
|
||||
error_info: None,
|
||||
}))
|
||||
}
|
||||
@@ -2257,7 +2258,7 @@ mod tests {
|
||||
|
||||
let request = Request::new(PingRequest {
|
||||
version: 1,
|
||||
body: fbb.finished_data().to_vec(),
|
||||
body: Bytes::copy_from_slice(fbb.finished_data()),
|
||||
});
|
||||
|
||||
let response = service.ping(request).await;
|
||||
@@ -2274,7 +2275,7 @@ mod tests {
|
||||
|
||||
let request = Request::new(PingRequest {
|
||||
version: 1,
|
||||
body: vec![0x00, 0x01, 0x02], // Invalid flatbuffer data
|
||||
body: vec![0x00, 0x01, 0x02].into(), // Invalid flatbuffer data
|
||||
});
|
||||
|
||||
let response = service.ping(request).await;
|
||||
@@ -2397,7 +2398,7 @@ mod tests {
|
||||
disk: "invalid-disk-path".to_string(),
|
||||
volume: "test-volume".to_string(),
|
||||
path: "test-path".to_string(),
|
||||
data: vec![1, 2, 3, 4],
|
||||
data: vec![1, 2, 3, 4].into(),
|
||||
});
|
||||
|
||||
let response = service.write_all(request).await;
|
||||
@@ -2514,7 +2515,7 @@ mod tests {
|
||||
src_path: "src-path".to_string(),
|
||||
dst_volume: "dst-volume".to_string(),
|
||||
dst_path: "dst-path".to_string(),
|
||||
meta: vec![],
|
||||
meta: Bytes::new(),
|
||||
});
|
||||
|
||||
let response = service.rename_part(request).await;
|
||||
|
||||
Reference in New Issue
Block a user