refactor error framework

Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
junxiang Mu
2024-12-18 20:50:22 +08:00
parent 2951b7ef28
commit 84953bf15b
13 changed files with 957 additions and 291 deletions
@@ -1,6 +1,13 @@
// This file is @generated by prost-build.
/// --------------------------------------------------------------------
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
#[prost(uint32, tag = "1")]
pub code: u32,
#[prost(string, tag = "2")]
pub error_info: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PingRequest {
#[prost(uint64, tag = "1")]
pub version: u64,
@@ -25,8 +32,8 @@ pub struct HealBucketRequest {
pub struct HealBucketResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListBucketRequest {
@@ -39,8 +46,8 @@ pub struct ListBucketResponse {
pub success: bool,
#[prost(string, repeated, tag = "2")]
pub bucket_infos: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MakeBucketRequest {
@@ -53,8 +60,8 @@ pub struct MakeBucketRequest {
pub struct MakeBucketResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBucketInfoRequest {
@@ -69,8 +76,8 @@ pub struct GetBucketInfoResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub bucket_info: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteBucketRequest {
@@ -81,8 +88,8 @@ pub struct DeleteBucketRequest {
pub struct DeleteBucketResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadAllRequest {
@@ -100,8 +107,8 @@ pub struct ReadAllResponse {
pub success: bool,
#[prost(bytes = "vec", tag = "2")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteAllRequest {
@@ -119,8 +126,8 @@ pub struct WriteAllRequest {
pub struct WriteAllResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRequest {
@@ -138,8 +145,8 @@ pub struct DeleteRequest {
pub struct DeleteResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerifyFileRequest {
@@ -159,8 +166,8 @@ pub struct VerifyFileResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub check_parts_resp: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CheckPartsRequest {
@@ -180,8 +187,8 @@ pub struct CheckPartsResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub check_parts_resp: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RenamePartRequst {
@@ -202,8 +209,8 @@ pub struct RenamePartRequst {
pub struct RenamePartResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RenameFileRequst {
@@ -222,8 +229,8 @@ pub struct RenameFileRequst {
pub struct RenameFileResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteRequest {
@@ -243,8 +250,8 @@ pub struct WriteRequest {
pub struct WriteResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadAtRequest {
@@ -268,8 +275,8 @@ pub struct ReadAtResponse {
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(int64, tag = "3")]
pub read_size: i64,
#[prost(string, optional, tag = "4")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "4")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListDirRequest {
@@ -285,8 +292,8 @@ pub struct ListDirResponse {
pub success: bool,
#[prost(string, repeated, tag = "2")]
pub volumes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WalkDirRequest {
@@ -302,8 +309,8 @@ pub struct WalkDirResponse {
pub success: bool,
#[prost(string, repeated, tag = "2")]
pub meta_cache_entry: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RenameDataRequest {
@@ -327,8 +334,8 @@ pub struct RenameDataResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub rename_data_resp: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MakeVolumesRequest {
@@ -342,8 +349,8 @@ pub struct MakeVolumesRequest {
pub struct MakeVolumesResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MakeVolumeRequest {
@@ -357,8 +364,8 @@ pub struct MakeVolumeRequest {
pub struct MakeVolumeResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListVolumesRequest {
@@ -372,8 +379,8 @@ pub struct ListVolumesResponse {
pub success: bool,
#[prost(string, repeated, tag = "2")]
pub volume_infos: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatVolumeRequest {
@@ -389,8 +396,8 @@ pub struct StatVolumeResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub volume_info: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeletePathsRequest {
@@ -405,8 +412,8 @@ pub struct DeletePathsRequest {
pub struct DeletePathsResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateMetadataRequest {
@@ -425,8 +432,8 @@ pub struct UpdateMetadataRequest {
pub struct UpdateMetadataResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteMetadataRequest {
@@ -444,8 +451,8 @@ pub struct WriteMetadataRequest {
pub struct WriteMetadataResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadVersionRequest {
@@ -466,8 +473,8 @@ pub struct ReadVersionResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub file_info: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadXlRequest {
@@ -486,8 +493,8 @@ pub struct ReadXlResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub raw_file_info: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteVersionRequest {
@@ -510,8 +517,8 @@ pub struct DeleteVersionResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub raw_file_info: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteVersionsRequest {
@@ -530,8 +537,8 @@ pub struct DeleteVersionsResponse {
pub success: bool,
#[prost(string, repeated, tag = "2")]
pub errors: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadMultipleRequest {
@@ -546,8 +553,8 @@ pub struct ReadMultipleResponse {
pub success: bool,
#[prost(string, repeated, tag = "2")]
pub read_multiple_resps: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteVolumeRequest {
@@ -560,8 +567,8 @@ pub struct DeleteVolumeRequest {
pub struct DeleteVolumeResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, optional, tag = "2")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DiskInfoRequest {
@@ -576,8 +583,8 @@ pub struct DiskInfoResponse {
pub success: bool,
#[prost(string, tag = "2")]
pub disk_info: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NsScannerRequest {
@@ -596,8 +603,8 @@ pub struct NsScannerResponse {
pub update: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub data_usage_cache: ::prost::alloc::string::String,
#[prost(string, optional, tag = "4")]
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "4")]
pub error: ::core::option::Option<Error>,
}
/// lock api have same argument type
#[derive(Clone, PartialEq, ::prost::Message)]
+38 -33
View File
@@ -2,6 +2,11 @@ syntax = "proto3";
package node_service;
/* -------------------------------------------------------------------- */
message Error {
uint32 code = 1;
string error_info = 2;
}
message PingRequest {
uint64 version = 1;
bytes body = 2;
@@ -19,7 +24,7 @@ message HealBucketRequest {
message HealBucketResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message ListBucketRequest {
@@ -29,7 +34,7 @@ message ListBucketRequest {
message ListBucketResponse {
bool success = 1;
repeated string bucket_infos = 2;
optional string error_info = 3;
optional Error error = 3;
}
message MakeBucketRequest {
@@ -39,7 +44,7 @@ message MakeBucketRequest {
message MakeBucketResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message GetBucketInfoRequest {
@@ -50,7 +55,7 @@ message GetBucketInfoRequest {
message GetBucketInfoResponse {
bool success = 1;
string bucket_info = 2;
optional string error_info = 3;
optional Error error = 3;
}
message DeleteBucketRequest {
@@ -59,7 +64,7 @@ message DeleteBucketRequest {
message DeleteBucketResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message ReadAllRequest {
@@ -71,7 +76,7 @@ message ReadAllRequest {
message ReadAllResponse {
bool success = 1;
bytes data = 2;
optional string error_info = 3;
optional Error error = 3;
}
message WriteAllRequest {
@@ -83,7 +88,7 @@ message WriteAllRequest {
message WriteAllResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message DeleteRequest {
@@ -95,7 +100,7 @@ message DeleteRequest {
message DeleteResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message VerifyFileRequest {
@@ -108,7 +113,7 @@ message VerifyFileRequest {
message VerifyFileResponse {
bool success = 1;
string check_parts_resp = 2;
optional string error_info = 3;
optional Error error = 3;
}
message CheckPartsRequest {
@@ -121,7 +126,7 @@ message CheckPartsRequest {
message CheckPartsResponse {
bool success = 1;
string check_parts_resp = 2;
optional string error_info = 3;
optional Error error = 3;
}
message RenamePartRequst {
@@ -135,7 +140,7 @@ message RenamePartRequst {
message RenamePartResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message RenameFileRequst {
@@ -148,7 +153,7 @@ message RenameFileRequst {
message RenameFileResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message WriteRequest {
@@ -161,7 +166,7 @@ message WriteRequest {
message WriteResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
// message AppendRequest {
@@ -173,7 +178,7 @@ message WriteResponse {
//
// message AppendResponse {
// bool success = 1;
// optional string error_info = 2;
// optional Error error = 2;
// }
message ReadAtRequest {
@@ -188,7 +193,7 @@ message ReadAtResponse {
bool success = 1;
bytes data = 2;
int64 read_size = 3;
optional string error_info = 4;
optional Error error = 4;
}
message ListDirRequest {
@@ -199,7 +204,7 @@ message ListDirRequest {
message ListDirResponse {
bool success = 1;
repeated string volumes = 2;
optional string error_info = 3;
optional Error error = 3;
}
message WalkDirRequest {
@@ -210,7 +215,7 @@ message WalkDirRequest {
message WalkDirResponse {
bool success = 1;
repeated string meta_cache_entry = 2;
optional string error_info = 3;
optional Error error = 3;
}
message RenameDataRequest {
@@ -225,7 +230,7 @@ message RenameDataRequest {
message RenameDataResponse {
bool success = 1;
string rename_data_resp = 2;
optional string error_info = 3;
optional Error error = 3;
}
message MakeVolumesRequest {
@@ -235,7 +240,7 @@ message MakeVolumesRequest {
message MakeVolumesResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message MakeVolumeRequest {
@@ -245,7 +250,7 @@ message MakeVolumeRequest {
message MakeVolumeResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message ListVolumesRequest {
@@ -255,7 +260,7 @@ message ListVolumesRequest {
message ListVolumesResponse {
bool success = 1;
repeated string volume_infos = 2;
optional string error_info = 3;
optional Error error = 3;
}
message StatVolumeRequest {
@@ -266,7 +271,7 @@ message StatVolumeRequest {
message StatVolumeResponse {
bool success = 1;
string volume_info = 2;
optional string error_info = 3;
optional Error error = 3;
}
message DeletePathsRequest {
@@ -277,7 +282,7 @@ message DeletePathsRequest {
message DeletePathsResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message UpdateMetadataRequest {
@@ -290,7 +295,7 @@ message UpdateMetadataRequest {
message UpdateMetadataResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message WriteMetadataRequest {
@@ -302,7 +307,7 @@ message WriteMetadataRequest {
message WriteMetadataResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message ReadVersionRequest {
@@ -316,7 +321,7 @@ message ReadVersionRequest {
message ReadVersionResponse {
bool success = 1;
string file_info = 2;
optional string error_info = 3;
optional Error error = 3;
}
message ReadXLRequest {
@@ -329,7 +334,7 @@ message ReadXLRequest {
message ReadXLResponse {
bool success = 1;
string raw_file_info = 2;
optional string error_info = 3;
optional Error error = 3;
}
message DeleteVersionRequest {
@@ -344,7 +349,7 @@ message DeleteVersionRequest {
message DeleteVersionResponse {
bool success = 1;
string raw_file_info = 2;
optional string error_info = 3;
optional Error error = 3;
}
message DeleteVersionsRequest {
@@ -357,7 +362,7 @@ message DeleteVersionsRequest {
message DeleteVersionsResponse {
bool success = 1;
repeated string errors = 2;
optional string error_info = 3;
optional Error error = 3;
}
message ReadMultipleRequest {
@@ -368,7 +373,7 @@ message ReadMultipleRequest {
message ReadMultipleResponse {
bool success = 1;
repeated string read_multiple_resps = 2;
optional string error_info = 3;
optional Error error = 3;
}
message DeleteVolumeRequest {
@@ -378,7 +383,7 @@ message DeleteVolumeRequest {
message DeleteVolumeResponse {
bool success = 1;
optional string error_info = 2;
optional Error error = 2;
}
message DiskInfoRequest {
@@ -389,7 +394,7 @@ message DiskInfoRequest {
message DiskInfoResponse {
bool success = 1;
string disk_info = 2;
optional string error_info = 3;
optional Error error = 3;
}
message NsScannerRequest {
@@ -402,7 +407,7 @@ message NsScannerResponse {
bool success = 1;
string update = 2;
string data_usage_cache = 3;
optional string error_info = 4;
optional Error error = 4;
}
// lock api have same argument type