d_engine/generated/
raft.common.rs

1// This file is @generated by prost-build.
2/// Basic definitions shared across modules
3#[derive(serde::Serialize, serde::Deserialize)]
4#[derive(Clone, Copy, PartialEq, ::prost::Message)]
5pub struct LogId {
6    #[prost(uint64, tag = "1")]
7    pub term: u64,
8    #[prost(uint64, tag = "2")]
9    pub index: u64,
10}
11/// Raft log entry
12#[derive(serde::Serialize, serde::Deserialize)]
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct Entry {
15    #[prost(uint64, tag = "1")]
16    pub index: u64,
17    #[prost(uint64, tag = "2")]
18    pub term: u64,
19    #[prost(message, optional, tag = "3")]
20    pub payload: ::core::option::Option<EntryPayload>,
21}
22/// Log entry payload
23#[derive(serde::Serialize, serde::Deserialize)]
24#[derive(Clone, PartialEq, ::prost::Message)]
25pub struct EntryPayload {
26    #[prost(oneof = "entry_payload::Payload", tags = "1, 2, 3")]
27    pub payload: ::core::option::Option<entry_payload::Payload>,
28}
29/// Nested message and enum types in `EntryPayload`.
30pub mod entry_payload {
31    #[derive(serde::Serialize, serde::Deserialize)]
32    #[derive(Clone, PartialEq, ::prost::Oneof)]
33    pub enum Payload {
34        /// No operation (internal to the protocol)
35        #[prost(message, tag = "1")]
36        Noop(super::Noop),
37        /// Business write operation
38        #[prost(bytes, tag = "2")]
39        Command(::prost::alloc::vec::Vec<u8>),
40        /// Cluster configuration change
41        #[prost(message, tag = "3")]
42        Config(super::MembershipChange),
43    }
44}
45/// Internal operation of the protocol
46#[derive(serde::Serialize, serde::Deserialize)]
47#[derive(Clone, Copy, PartialEq, ::prost::Message)]
48pub struct Noop {}
49/// Cluster configuration change
50#[derive(serde::Serialize, serde::Deserialize)]
51#[derive(Clone, PartialEq, ::prost::Message)]
52pub struct MembershipChange {
53    #[prost(oneof = "membership_change::Change", tags = "1, 2, 3, 4, 5")]
54    pub change: ::core::option::Option<membership_change::Change>,
55}
56/// Nested message and enum types in `MembershipChange`.
57pub mod membership_change {
58    #[derive(serde::Serialize, serde::Deserialize)]
59    #[derive(Clone, PartialEq, ::prost::Oneof)]
60    pub enum Change {
61        #[prost(message, tag = "1")]
62        AddNode(super::AddNode),
63        #[prost(message, tag = "2")]
64        RemoveNode(super::RemoveNode),
65        #[prost(message, tag = "3")]
66        Promote(super::PromoteLearner),
67        #[prost(message, tag = "4")]
68        BatchPromote(super::BatchPromote),
69        #[prost(message, tag = "5")]
70        BatchRemove(super::BatchRemove),
71    }
72}
73#[derive(serde::Serialize, serde::Deserialize)]
74#[derive(Clone, PartialEq, ::prost::Message)]
75pub struct AddNode {
76    #[prost(uint32, tag = "1")]
77    pub node_id: u32,
78    #[prost(string, tag = "2")]
79    pub address: ::prost::alloc::string::String,
80}
81#[derive(serde::Serialize, serde::Deserialize)]
82#[derive(Clone, Copy, PartialEq, ::prost::Message)]
83pub struct RemoveNode {
84    #[prost(uint32, tag = "1")]
85    pub node_id: u32,
86}
87#[derive(serde::Serialize, serde::Deserialize)]
88#[derive(Clone, Copy, PartialEq, ::prost::Message)]
89pub struct PromoteLearner {
90    #[prost(uint32, tag = "1")]
91    pub node_id: u32,
92    #[prost(enumeration = "NodeStatus", tag = "2")]
93    pub status: i32,
94}
95#[derive(serde::Serialize, serde::Deserialize)]
96#[derive(Clone, PartialEq, ::prost::Message)]
97pub struct BatchPromote {
98    #[prost(uint32, repeated, tag = "1")]
99    pub node_ids: ::prost::alloc::vec::Vec<u32>,
100    #[prost(enumeration = "NodeStatus", tag = "2")]
101    pub new_status: i32,
102}
103#[derive(serde::Serialize, serde::Deserialize)]
104#[derive(Clone, PartialEq, ::prost::Message)]
105pub struct BatchRemove {
106    #[prost(uint32, repeated, tag = "1")]
107    pub node_ids: ::prost::alloc::vec::Vec<u32>,
108}
109#[derive(serde::Serialize, serde::Deserialize)]
110#[derive(Clone, PartialEq, ::prost::Message)]
111pub struct SnapshotEntry {
112    #[prost(bytes = "vec", tag = "1")]
113    pub key: ::prost::alloc::vec::Vec<u8>,
114    #[prost(bytes = "vec", tag = "2")]
115    pub value: ::prost::alloc::vec::Vec<u8>,
116}
117#[derive(serde::Serialize, serde::Deserialize)]
118#[derive(Clone, Copy, PartialEq, ::prost::Message)]
119pub struct SnapshotMeta {
120    #[prost(uint64, tag = "1")]
121    pub version_high: u64,
122    #[prost(uint64, tag = "2")]
123    pub version_low: u64,
124    #[prost(uint64, tag = "3")]
125    pub created_at_high: u64,
126    #[prost(uint64, tag = "4")]
127    pub created_at_low: u64,
128    #[prost(uint32, tag = "5")]
129    pub author_id: u32,
130    #[prost(message, optional, tag = "6")]
131    pub last_included: ::core::option::Option<LogId>,
132}
133#[derive(serde::Serialize, serde::Deserialize)]
134#[derive(Clone, PartialEq, ::prost::Message)]
135pub struct Snapshot {
136    #[prost(message, optional, tag = "1")]
137    pub meta: ::core::option::Option<SnapshotMeta>,
138    #[prost(message, repeated, tag = "2")]
139    pub data: ::prost::alloc::vec::Vec<SnapshotEntry>,
140}
141#[derive(serde::Serialize, serde::Deserialize)]
142#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
143#[repr(i32)]
144pub enum NodeStatus {
145    /// Initial joining process
146    ///
147    /// New node, catching up with logs
148    Joining = 0,
149    /// Start syncing with leader committed logs
150    Syncing = 1,
151    /// Running status
152    ///
153    /// Formal voting member
154    Active = 2,
155    /// Disaster recovery ready node (data has been synchronized)
156    StandBy = 3,
157    /// Offline process
158    ///
159    /// Prepare to go offline (not accepting new requests, transfer data)
160    Draining = 4,
161    /// Retiring (data migration completed)
162    Retiring = 5,
163    /// Zombie node (removed from cluster)
164    Zombie = 6,
165}
166impl NodeStatus {
167    /// String value of the enum field names used in the ProtoBuf definition.
168    ///
169    /// The values are not transformed in any way and thus are considered stable
170    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
171    pub fn as_str_name(&self) -> &'static str {
172        match self {
173            Self::Joining => "JOINING",
174            Self::Syncing => "SYNCING",
175            Self::Active => "ACTIVE",
176            Self::StandBy => "STAND_BY",
177            Self::Draining => "DRAINING",
178            Self::Retiring => "RETIRING",
179            Self::Zombie => "ZOMBIE",
180        }
181    }
182    /// Creates an enum from field names used in the ProtoBuf definition.
183    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
184        match value {
185            "JOINING" => Some(Self::Joining),
186            "SYNCING" => Some(Self::Syncing),
187            "ACTIVE" => Some(Self::Active),
188            "STAND_BY" => Some(Self::StandBy),
189            "DRAINING" => Some(Self::Draining),
190            "RETIRING" => Some(Self::Retiring),
191            "ZOMBIE" => Some(Self::Zombie),
192            _ => None,
193        }
194    }
195}