forked from tikv/client-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplication_modepb.rs
More file actions
128 lines (128 loc) · 4.84 KB
/
replication_modepb.rs
File metadata and controls
128 lines (128 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// This file is @generated by prost-build.
/// The replication status sync from PD to TiKV.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReplicationStatus {
#[prost(enumeration = "ReplicationMode", tag = "1")]
pub mode: i32,
#[prost(message, optional, tag = "2")]
pub dr_auto_sync: ::core::option::Option<DrAutoSync>,
}
/// The status of dr-autosync mode.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DrAutoSync {
/// The key of the label that used for distinguish different DC.
#[prost(string, tag = "1")]
pub label_key: ::prost::alloc::string::String,
#[prost(enumeration = "DrAutoSyncState", tag = "2")]
pub state: i32,
/// Unique ID of the state, it increases after each state transfer.
#[prost(uint64, tag = "3")]
pub state_id: u64,
/// Duration to wait before switching to SYNC by force (in seconds)
#[prost(int32, tag = "4")]
pub wait_sync_timeout_hint: i32,
}
/// The replication status sync from TiKV to PD.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionReplicationStatus {
#[prost(enumeration = "RegionReplicationState", tag = "1")]
pub state: i32,
/// Unique ID of the state, it increases after each state transfer.
#[prost(uint64, tag = "2")]
pub state_id: u64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ReplicationMode {
/// The standard mode. Replicate logs to majority peer.
Majority = 0,
/// DR mode. Replicate logs among 2 DCs.
DrAutoSync = 1,
}
impl ReplicationMode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ReplicationMode::Majority => "MAJORITY",
ReplicationMode::DrAutoSync => "DR_AUTO_SYNC",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MAJORITY" => Some(Self::Majority),
"DR_AUTO_SYNC" => Some(Self::DrAutoSync),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DrAutoSyncState {
/// Raft logs need to sync between different DCs
Sync = 0,
/// Raft logs need to sync to majority peers
Async = 1,
/// Switching from ASYNC to SYNC mode
SyncRecover = 2,
}
impl DrAutoSyncState {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
DrAutoSyncState::Sync => "SYNC",
DrAutoSyncState::Async => "ASYNC",
DrAutoSyncState::SyncRecover => "SYNC_RECOVER",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SYNC" => Some(Self::Sync),
"ASYNC" => Some(Self::Async),
"SYNC_RECOVER" => Some(Self::SyncRecover),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum RegionReplicationState {
/// The region's state is unknown
Unknown = 0,
/// Logs sync to majority peers
SimpleMajority = 1,
/// Logs sync to different DCs
IntegrityOverLabel = 2,
}
impl RegionReplicationState {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
RegionReplicationState::Unknown => "UNKNOWN",
RegionReplicationState::SimpleMajority => "SIMPLE_MAJORITY",
RegionReplicationState::IntegrityOverLabel => "INTEGRITY_OVER_LABEL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN" => Some(Self::Unknown),
"SIMPLE_MAJORITY" => Some(Self::SimpleMajority),
"INTEGRITY_OVER_LABEL" => Some(Self::IntegrityOverLabel),
_ => None,
}
}
}