feat(protos): use Bytes for protobuf bytes type fields.

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