mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-17 18:27:49 +00:00
refactor: update binary field types and conversions in RPC and protofiles (#2619)
Signed-off-by: 唐小鸭 <tangtang1251@qq.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: houseme <housemecn@gmail.com> Co-authored-by: loverustfs <hello@rustfs.com>
This commit is contained in:
@@ -131,6 +131,7 @@ impl NodeService {
|
||||
.iter()
|
||||
.filter_map(|json_str| serde_json::from_str::<ReadMultipleResp>(json_str).ok())
|
||||
.filter_map(|resp| encode_msgpack(&resp, "ReadMultipleResp").ok())
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
|
||||
Ok(Response::new(ReadMultipleResponse {
|
||||
@@ -279,19 +280,19 @@ impl NodeService {
|
||||
(Ok(raw_file_info), Ok(raw_file_info_bin)) => Ok(Response::new(ReadXlResponse {
|
||||
success: true,
|
||||
raw_file_info,
|
||||
raw_file_info_bin,
|
||||
raw_file_info_bin: raw_file_info_bin.into(),
|
||||
error: None,
|
||||
})),
|
||||
(Err(err), _) => Ok(Response::new(ReadXlResponse {
|
||||
success: false,
|
||||
raw_file_info: String::new(),
|
||||
raw_file_info_bin: Vec::new(),
|
||||
raw_file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
|
||||
})),
|
||||
(_, Err(err)) => Ok(Response::new(ReadXlResponse {
|
||||
success: false,
|
||||
raw_file_info: String::new(),
|
||||
raw_file_info_bin: Vec::new(),
|
||||
raw_file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
|
||||
})),
|
||||
}
|
||||
@@ -299,7 +300,7 @@ impl NodeService {
|
||||
Err(err) => Ok(Response::new(ReadXlResponse {
|
||||
success: false,
|
||||
raw_file_info: String::new(),
|
||||
raw_file_info_bin: Vec::new(),
|
||||
raw_file_info_bin: Vec::new().into(),
|
||||
error: Some(err.into()),
|
||||
})),
|
||||
}
|
||||
@@ -307,7 +308,7 @@ impl NodeService {
|
||||
Ok(Response::new(ReadXlResponse {
|
||||
success: false,
|
||||
raw_file_info: String::new(),
|
||||
raw_file_info_bin: Vec::new(),
|
||||
raw_file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other("can not find disk".to_string()).into()),
|
||||
}))
|
||||
}
|
||||
@@ -325,7 +326,7 @@ impl NodeService {
|
||||
return Ok(Response::new(ReadVersionResponse {
|
||||
success: false,
|
||||
file_info: String::new(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other(format!("decode ReadOptions failed: {err}")).into()),
|
||||
}));
|
||||
}
|
||||
@@ -341,19 +342,19 @@ impl NodeService {
|
||||
(Ok(file_info), Ok(file_info_bin)) => Ok(Response::new(ReadVersionResponse {
|
||||
success: true,
|
||||
file_info,
|
||||
file_info_bin,
|
||||
file_info_bin: file_info_bin.into(),
|
||||
error: None,
|
||||
})),
|
||||
(Err(err), _) => Ok(Response::new(ReadVersionResponse {
|
||||
success: false,
|
||||
file_info: String::new(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
|
||||
})),
|
||||
(_, Err(err)) => Ok(Response::new(ReadVersionResponse {
|
||||
success: false,
|
||||
file_info: String::new(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
|
||||
})),
|
||||
}
|
||||
@@ -361,7 +362,7 @@ impl NodeService {
|
||||
Err(err) => Ok(Response::new(ReadVersionResponse {
|
||||
success: false,
|
||||
file_info: String::new(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
error: Some(err.into()),
|
||||
})),
|
||||
}
|
||||
@@ -369,7 +370,7 @@ impl NodeService {
|
||||
Ok(Response::new(ReadVersionResponse {
|
||||
success: false,
|
||||
file_info: String::new(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
error: Some(DiskError::other("can not find disk".to_string()).into()),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1389,8 +1389,8 @@ mod tests {
|
||||
path: "test-path".to_string(),
|
||||
file_info: "{}".to_string(),
|
||||
opts: "{}".to_string(),
|
||||
file_info_bin: Vec::new(),
|
||||
opts_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
opts_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.update_metadata(request).await;
|
||||
@@ -1411,8 +1411,8 @@ mod tests {
|
||||
path: "test-path".to_string(),
|
||||
file_info: "invalid json".to_string(),
|
||||
opts: "{}".to_string(),
|
||||
file_info_bin: Vec::new(),
|
||||
opts_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
opts_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.update_metadata(request).await;
|
||||
@@ -1433,8 +1433,8 @@ mod tests {
|
||||
path: "test-path".to_string(),
|
||||
file_info: "{}".to_string(),
|
||||
opts: "invalid json".to_string(),
|
||||
file_info_bin: Vec::new(),
|
||||
opts_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
opts_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.update_metadata(request).await;
|
||||
@@ -1454,7 +1454,7 @@ mod tests {
|
||||
volume: "test-volume".to_string(),
|
||||
path: "test-path".to_string(),
|
||||
file_info: "{}".to_string(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.write_metadata(request).await;
|
||||
@@ -1474,7 +1474,7 @@ mod tests {
|
||||
volume: "test-volume".to_string(),
|
||||
path: "test-path".to_string(),
|
||||
file_info: "invalid json".to_string(),
|
||||
file_info_bin: Vec::new(),
|
||||
file_info_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.write_metadata(request).await;
|
||||
@@ -1495,7 +1495,7 @@ mod tests {
|
||||
path: "test-path".to_string(),
|
||||
version_id: "version1".to_string(),
|
||||
opts: "{}".to_string(),
|
||||
opts_bin: Vec::new(),
|
||||
opts_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.read_version(request).await;
|
||||
@@ -1517,7 +1517,7 @@ mod tests {
|
||||
path: "test-path".to_string(),
|
||||
version_id: "version1".to_string(),
|
||||
opts: "invalid json".to_string(),
|
||||
opts_bin: Vec::new(),
|
||||
opts_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.read_version(request).await;
|
||||
@@ -1675,7 +1675,7 @@ mod tests {
|
||||
let request = Request::new(ReadMultipleRequest {
|
||||
disk: "invalid-disk-path".to_string(),
|
||||
read_multiple_req: "{}".to_string(),
|
||||
read_multiple_req_bin: Vec::new(),
|
||||
read_multiple_req_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.read_multiple(request).await;
|
||||
@@ -1694,7 +1694,7 @@ mod tests {
|
||||
let request = Request::new(ReadMultipleRequest {
|
||||
disk: "invalid-disk-path".to_string(),
|
||||
read_multiple_req: "invalid json".to_string(),
|
||||
read_multiple_req_bin: Vec::new(),
|
||||
read_multiple_req_bin: Vec::new().into(),
|
||||
});
|
||||
|
||||
let response = service.read_multiple(request).await;
|
||||
|
||||
Reference in New Issue
Block a user