d_engine/generated/
raft.error.rs

1// This file is @generated by prost-build.
2#[derive(serde::Serialize, serde::Deserialize)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ErrorMetadata {
5    /// Errors suitable for retry
6    #[prost(uint64, optional, tag = "1")]
7    pub retry_after_ms: ::core::option::Option<u64>,
8    /// Leader change information
9    #[prost(string, optional, tag = "2")]
10    pub leader_id: ::core::option::Option<::prost::alloc::string::String>,
11    #[prost(string, optional, tag = "3")]
12    pub leader_address: ::core::option::Option<::prost::alloc::string::String>,
13    /// Error details (for debugging only)
14    #[prost(string, optional, tag = "15")]
15    pub debug_message: ::core::option::Option<::prost::alloc::string::String>,
16}
17#[derive(serde::Serialize, serde::Deserialize)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
19#[repr(i32)]
20pub enum ErrorCode {
21    /// Success status (non-error)
22    Success = 0,
23    /// ======================
24    /// Network layer error (1000-1999)
25    /// ======================
26    ConnectionTimeout = 1001,
27    InvalidAddress = 1002,
28    LeaderChanged = 1003,
29    JoinError = 1004,
30    /// ======================
31    /// Protocol layer error (2000-2999)
32    /// ======================
33    InvalidResponse = 2001,
34    VersionMismatch = 2002,
35    /// ======================
36    /// Storage layer error (3000-3999)
37    /// ======================
38    DiskFull = 3001,
39    DataCorruption = 3002,
40    StorageIoError = 3003,
41    StoragePermissionDenied = 3004,
42    KeyNotExist = 3005,
43    /// ======================
44    /// Business logic error (4000-4999)
45    /// ======================
46    NotLeader = 4001,
47    StaleOperation = 4002,
48    InvalidRequest = 4003,
49    RateLimited = 4004,
50    ClusterUnavailable = 4005,
51    ProposeFailed = 4006,
52    TermOutdated = 4007,
53    RetryRequired = 4008,
54    /// ======================
55    /// Unclassified error
56    /// ======================
57    General = 8888,
58    Uncategorized = 9999,
59}
60impl ErrorCode {
61    /// String value of the enum field names used in the ProtoBuf definition.
62    ///
63    /// The values are not transformed in any way and thus are considered stable
64    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
65    pub fn as_str_name(&self) -> &'static str {
66        match self {
67            Self::Success => "SUCCESS",
68            Self::ConnectionTimeout => "CONNECTION_TIMEOUT",
69            Self::InvalidAddress => "INVALID_ADDRESS",
70            Self::LeaderChanged => "LEADER_CHANGED",
71            Self::JoinError => "JOIN_ERROR",
72            Self::InvalidResponse => "INVALID_RESPONSE",
73            Self::VersionMismatch => "VERSION_MISMATCH",
74            Self::DiskFull => "DISK_FULL",
75            Self::DataCorruption => "DATA_CORRUPTION",
76            Self::StorageIoError => "STORAGE_IO_ERROR",
77            Self::StoragePermissionDenied => "STORAGE_PERMISSION_DENIED",
78            Self::KeyNotExist => "KEY_NOT_EXIST",
79            Self::NotLeader => "NOT_LEADER",
80            Self::StaleOperation => "STALE_OPERATION",
81            Self::InvalidRequest => "INVALID_REQUEST",
82            Self::RateLimited => "RATE_LIMITED",
83            Self::ClusterUnavailable => "CLUSTER_UNAVAILABLE",
84            Self::ProposeFailed => "PROPOSE_FAILED",
85            Self::TermOutdated => "TERM_OUTDATED",
86            Self::RetryRequired => "RETRY_REQUIRED",
87            Self::General => "GENERAL",
88            Self::Uncategorized => "UNCATEGORIZED",
89        }
90    }
91    /// Creates an enum from field names used in the ProtoBuf definition.
92    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
93        match value {
94            "SUCCESS" => Some(Self::Success),
95            "CONNECTION_TIMEOUT" => Some(Self::ConnectionTimeout),
96            "INVALID_ADDRESS" => Some(Self::InvalidAddress),
97            "LEADER_CHANGED" => Some(Self::LeaderChanged),
98            "JOIN_ERROR" => Some(Self::JoinError),
99            "INVALID_RESPONSE" => Some(Self::InvalidResponse),
100            "VERSION_MISMATCH" => Some(Self::VersionMismatch),
101            "DISK_FULL" => Some(Self::DiskFull),
102            "DATA_CORRUPTION" => Some(Self::DataCorruption),
103            "STORAGE_IO_ERROR" => Some(Self::StorageIoError),
104            "STORAGE_PERMISSION_DENIED" => Some(Self::StoragePermissionDenied),
105            "KEY_NOT_EXIST" => Some(Self::KeyNotExist),
106            "NOT_LEADER" => Some(Self::NotLeader),
107            "STALE_OPERATION" => Some(Self::StaleOperation),
108            "INVALID_REQUEST" => Some(Self::InvalidRequest),
109            "RATE_LIMITED" => Some(Self::RateLimited),
110            "CLUSTER_UNAVAILABLE" => Some(Self::ClusterUnavailable),
111            "PROPOSE_FAILED" => Some(Self::ProposeFailed),
112            "TERM_OUTDATED" => Some(Self::TermOutdated),
113            "RETRY_REQUIRED" => Some(Self::RetryRequired),
114            "GENERAL" => Some(Self::General),
115            "UNCATEGORIZED" => Some(Self::Uncategorized),
116            _ => None,
117        }
118    }
119}