feat: Add vendored support (#411)

* feat: Add vendored support

Signed-off-by: Xuanwo <github@xuanwo.io>

* Use diff=false instead

Signed-off-by: Xuanwo <github@xuanwo.io>

* try fix

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

* Use vendor by default

Signed-off-by: Xuanwo <github@xuanwo.io>

* Add check

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
Xuanwo 2023-07-21 15:44:38 +08:00 committed by GitHub
parent 2761270f6d
commit 8b3ada28ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 12722 additions and 17 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
src/generated/ diff=false

View File

@ -21,6 +21,9 @@ jobs:
uses: Swatinem/rust-cache@v1.4.0
- name: make check
run: make check
- name: Catch unexpected changes in the generated code
run: |
git diff --exit-code
unit-test:
name: unit test

View File

@ -17,6 +17,12 @@ integration-tests = []
[lib]
name = "tikv_client"
[workspace]
members = [
".",
"proto-build",
]
[dependencies]
async-recursion = "0.3"
async-trait = "0.1"
@ -39,7 +45,6 @@ tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] }
tonic = { version = "0.9", features = ["tls"] }
[dev-dependencies]
tempfile = "3.6"
clap = "2"
env_logger = "0.10"
fail = { version = "0.4", features = ["failpoints"] }
@ -51,14 +56,9 @@ reqwest = { version = "0.11", default-features = false, features = [
serde_json = "1"
serial_test = "0.5.0"
simple_logger = "1"
tempfile = "3.6"
tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] }
[build-dependencies]
glob = "0.3"
tonic-build = "0.9"
# Suppress doctest bug (https://stackoverflow.com/questions/66074003/how-to-turn-off-cargo-doc-test-and-compile-for-a-specific-module-in-rust)
tonic-disable-doctest = "0.1.0"
[[test]]
name = "failpoint_tests"
path = "tests/failpoint_tests.rs"

View File

@ -11,15 +11,18 @@ INTEGRATION_TEST_ARGS := --features "integration-tests"
default: check
check:
generate:
cargo run -p tikv-client-proto-build
check: generate
cargo check --all --all-targets --features "${ALL_FEATURES}"
cargo fmt -- --check
cargo clippy --all-targets --features "${ALL_FEATURES}" -- -D clippy::all
unit-test:
unit-test: generate
cargo test --all --no-default-features
integration-test:
integration-test: generate
cargo test txn_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
cargo test raw_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
cargo test misc_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
@ -32,7 +35,7 @@ doc:
tiup:
tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config $(shell pwd)/config/tikv.toml --pd.config $(shell pwd)/config/pd.toml &
all: check doc test
all: generate check doc test
clean:
cargo clean

17
proto-build/Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[package]
name = "tikv-client-proto-build"
version = "0.0.0"
publish = false
keywords = ["TiKV", "KV", "distributed-systems"]
license = "Apache-2.0"
authors = ["The TiKV Project Authors"]
repository = "https://github.com/tikv/client-rust"
description = "The Rust language implementation of TiKV client."
edition = "2021"
[dependencies]
glob = "0.3"
tonic-build = "0.9"
# Suppress doctest bug (https://stackoverflow.com/questions/66074003/how-to-turn-off-cargo-doc-test-and-compile-for-a-specific-module-in-rust)
tonic-disable-doctest = "0.1.0"

View File

@ -1,12 +1,14 @@
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use tonic_disable_doctest::BuilderEx;
// Copyright 2023 TiKV Project Authors. Licensed under Apache-2.0.
fn main() {
use tonic_disable_doctest::BuilderEx;
tonic_build::configure()
.disable_doctests_for_types([".google.api.HttpRule"])
.emit_rerun_if_changed(false)
.build_server(false)
.include_file("mod.rs")
.out_dir("src/generated")
.compile(
&glob::glob("proto/*.proto")
.unwrap()

700
src/generated/backup.rs Normal file
View File

@ -0,0 +1,700 @@
/// The message save the metadata of a backup.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BackupMeta {
/// ID and version of backuped cluster.
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
#[prost(string, tag = "2")]
pub cluster_version: ::prost::alloc::string::String,
/// Save the version of BR running backup jobs.
#[prost(string, tag = "11")]
pub br_version: ::prost::alloc::string::String,
/// The backupmeta scheme version.
#[prost(int32, tag = "12")]
pub version: i32,
/// A set of files that compose a backup.
/// Note: `files` is deprecated, as it bloats backupmeta. It is kept for
/// compatibility, so new BR can restore older backups.
#[prost(message, repeated, tag = "4")]
pub files: ::prost::alloc::vec::Vec<File>,
/// An index to files contains data files.
#[prost(message, optional, tag = "13")]
pub file_index: ::core::option::Option<MetaFile>,
/// A pair of timestamp specifies a time range of a backup.
/// For full backup, the start_version equals to the end_version,
/// it means point in time.
/// For incremental backup, the time range is specified as
/// (start_version, end_version].
#[prost(uint64, tag = "5")]
pub start_version: u64,
#[prost(uint64, tag = "6")]
pub end_version: u64,
/// Table metadata describes database and table info.
/// Note: `schemas` is deprecated, as it bloats backupmeta. It is kept for
/// compatibility, so new BR can restore older backups.
#[prost(message, repeated, tag = "7")]
pub schemas: ::prost::alloc::vec::Vec<Schema>,
/// An index to files contains Schemas.
#[prost(message, optional, tag = "14")]
pub schema_index: ::core::option::Option<MetaFile>,
/// If in raw kv mode, `start_versions`, `end_versions` and `schemas` will be
/// ignored, and the backup data's range is represented by raw_ranges.
#[prost(bool, tag = "8")]
pub is_raw_kv: bool,
/// Note: `raw_ranges` is deprecated, as it bloats backupmeta. It is kept for
/// compatibility, so new BR can restore older backups.
#[prost(message, repeated, tag = "9")]
pub raw_ranges: ::prost::alloc::vec::Vec<RawRange>,
/// An index to files contains RawRanges.
#[prost(message, optional, tag = "15")]
pub raw_range_index: ::core::option::Option<MetaFile>,
/// In incremental backup, DDLs which are completed in
/// (lastBackupTS, backupTS] will be stored here.
/// Note: `raw_ranges` is deprecated, as it bloats backupmeta. It is kept for
/// compatibility, so new BR can restore older backups.
#[prost(bytes = "vec", tag = "10")]
pub ddls: ::prost::alloc::vec::Vec<u8>,
/// An index to files contains DDLs.
#[prost(message, optional, tag = "16")]
pub ddl_indexes: ::core::option::Option<MetaFile>,
/// the backup result into `backupmeta` file
#[prost(string, tag = "17")]
pub backup_result: ::prost::alloc::string::String,
/// API version implies the encode of the key and value.
#[prost(enumeration = "super::kvrpcpb::ApiVersion", tag = "18")]
pub api_version: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct File {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub sha256: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "4")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "5")]
pub start_version: u64,
#[prost(uint64, tag = "6")]
pub end_version: u64,
#[prost(uint64, tag = "7")]
pub crc64xor: u64,
#[prost(uint64, tag = "8")]
pub total_kvs: u64,
#[prost(uint64, tag = "9")]
pub total_bytes: u64,
#[prost(string, tag = "10")]
pub cf: ::prost::alloc::string::String,
#[prost(uint64, tag = "11")]
pub size: u64,
/// cipher_iv is used for AES cipher
#[prost(bytes = "vec", tag = "12")]
pub cipher_iv: ::prost::alloc::vec::Vec<u8>,
}
/// MetaFile describes a multi-level index of data used in backup.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MetaFile {
/// A set of files that contains a MetaFile.
/// It is used as a multi-level index.
#[prost(message, repeated, tag = "1")]
pub meta_files: ::prost::alloc::vec::Vec<File>,
/// A set of files that contains user data.
#[prost(message, repeated, tag = "2")]
pub data_files: ::prost::alloc::vec::Vec<File>,
/// A set of files that contains Schemas.
#[prost(message, repeated, tag = "3")]
pub schemas: ::prost::alloc::vec::Vec<Schema>,
/// A set of files that contains RawRanges.
#[prost(message, repeated, tag = "4")]
pub raw_ranges: ::prost::alloc::vec::Vec<RawRange>,
/// A set of files that contains DDLs.
#[prost(bytes = "vec", repeated, tag = "5")]
pub ddls: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Schema {
#[prost(bytes = "vec", tag = "1")]
pub db: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub table: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "3")]
pub crc64xor: u64,
#[prost(uint64, tag = "4")]
pub total_kvs: u64,
#[prost(uint64, tag = "5")]
pub total_bytes: u64,
#[prost(uint32, tag = "6")]
pub tiflash_replicas: u32,
/// stats represents the dump stats for a analyzed table, which generate by DumpStatsToJSON
/// <https://github.com/pingcap/tidb/blob/e136429d8dc5d70f43cd3f94179b0b9f47595097/statistics/handle/dump.go#L116>
#[prost(bytes = "vec", tag = "7")]
pub stats: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RawRange {
#[prost(bytes = "vec", tag = "1")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag = "3")]
pub cf: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClusterIdError {
#[prost(uint64, tag = "1")]
pub current: u64,
#[prost(uint64, tag = "2")]
pub request: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
#[prost(string, tag = "1")]
pub msg: ::prost::alloc::string::String,
#[prost(oneof = "error::Detail", tags = "3, 4, 5")]
pub detail: ::core::option::Option<error::Detail>,
}
/// Nested message and enum types in `Error`.
pub mod error {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Detail {
#[prost(message, tag = "3")]
ClusterIdError(super::ClusterIdError),
#[prost(message, tag = "4")]
KvError(super::super::kvrpcpb::KeyError),
#[prost(message, tag = "5")]
RegionError(super::super::errorpb::Error),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CipherInfo {
#[prost(enumeration = "super::encryptionpb::EncryptionMethod", tag = "1")]
pub cipher_type: i32,
#[prost(bytes = "vec", tag = "2")]
pub cipher_key: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BackupRequest {
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
#[prost(bytes = "vec", tag = "2")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "4")]
pub start_version: u64,
#[prost(uint64, tag = "5")]
pub end_version: u64,
/// The I/O rate limit for backup request.
#[prost(uint64, tag = "7")]
pub rate_limit: u64,
/// The concurrency for executing the backup request in every tikv node.
#[prost(uint32, tag = "8")]
pub concurrency: u32,
#[prost(message, optional, tag = "9")]
pub storage_backend: ::core::option::Option<StorageBackend>,
/// If raw kv mode is enabled, `start_version` and `end_version` will be ignored, and `cf`
/// specifies which cf to backup.
#[prost(bool, tag = "10")]
pub is_raw_kv: bool,
#[prost(string, tag = "11")]
pub cf: ::prost::alloc::string::String,
/// algorithm used for compress sst files
#[prost(enumeration = "CompressionType", tag = "12")]
pub compression_type: i32,
/// sst compression level, some algorithms support negative compression levels
#[prost(int32, tag = "13")]
pub compression_level: i32,
/// The cipher_info is Used to encrypt sst
#[prost(message, optional, tag = "14")]
pub cipher_info: ::core::option::Option<CipherInfo>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StorageBackend {
#[prost(oneof = "storage_backend::Backend", tags = "1, 2, 3, 4, 5, 6, 7")]
pub backend: ::core::option::Option<storage_backend::Backend>,
}
/// Nested message and enum types in `StorageBackend`.
pub mod storage_backend {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Backend {
#[prost(message, tag = "1")]
Noop(super::Noop),
#[prost(message, tag = "2")]
Local(super::Local),
#[prost(message, tag = "3")]
S3(super::S3),
#[prost(message, tag = "4")]
Gcs(super::Gcs),
#[prost(message, tag = "5")]
CloudDynamic(super::CloudDynamic),
#[prost(message, tag = "6")]
Hdfs(super::Hdfs),
#[prost(message, tag = "7")]
AzureBlobStorage(super::AzureBlobStorage),
}
}
/// Noop storage backend saves files into void.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Noop {}
/// Local storage backend saves files into local disk
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Local {
#[prost(string, tag = "1")]
pub path: ::prost::alloc::string::String,
}
/// S3 storage backend saves files into S3 compatible storages
/// For non-aws providers, endpoint must be provided
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct S3 {
#[prost(string, tag = "1")]
pub endpoint: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub region: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub bucket: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub prefix: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub storage_class: ::prost::alloc::string::String,
/// server side encryption
#[prost(string, tag = "6")]
pub sse: ::prost::alloc::string::String,
#[prost(string, tag = "7")]
pub acl: ::prost::alloc::string::String,
#[prost(string, tag = "8")]
pub access_key: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
pub secret_access_key: ::prost::alloc::string::String,
#[prost(bool, tag = "10")]
pub force_path_style: bool,
#[prost(string, tag = "11")]
pub sse_kms_key_id: ::prost::alloc::string::String,
}
/// GCS storage backend saves files into google cloud storage.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Gcs {
#[prost(string, tag = "1")]
pub endpoint: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub bucket: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub prefix: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub storage_class: ::prost::alloc::string::String,
/// If not empty, applies a predefined set of access controls.
/// See <https://cloud.google.com/storage/docs/access-control/lists#predefined-acl>
/// for valid values.
#[prost(string, tag = "5")]
pub predefined_acl: ::prost::alloc::string::String,
/// Service Account Credentials JSON blob
/// You can get one from <https://console.cloud.google.com/apis/credentials,> and
/// copy the content, set it as string here.
#[prost(string, tag = "6")]
pub credentials_blob: ::prost::alloc::string::String,
}
/// AzureBlobStorage storage backend saves files into azure blob storage.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AzureBlobStorage {
#[prost(string, tag = "1")]
pub endpoint: ::prost::alloc::string::String,
/// Alias: container
#[prost(string, tag = "2")]
pub bucket: ::prost::alloc::string::String,
/// Notice: prefix starts without `/`, otherwise the first directory's name is empty.
#[prost(string, tag = "3")]
pub prefix: ::prost::alloc::string::String,
/// Alias: access_tier.
/// See <https://docs.microsoft.com/en-us/azure/storage/blobs/access-tiers-overview>
#[prost(string, tag = "4")]
pub storage_class: ::prost::alloc::string::String,
/// if empty, try to read account_name from the node's environment variable $AZURE_STORAGE_ACCOUNT.
#[prost(string, tag = "5")]
pub account_name: ::prost::alloc::string::String,
/// Use shared key to access the azure blob
/// If the node's environment variables($AZURE_CLIENT_ID, $AZURE_TENANT_ID, $AZURE_CLIENT_SECRET) exist,
/// prefer to use token to access the azure blob.
///
/// See <https://docs.microsoft.com/en-us/azure/storage/common/identity-library-acquire-token?toc=/azure/storage/blobs/toc.json>
///
/// Otherwise, if empty, try to read shared key from the node's environment variable $AZURE_STORAGE_KEY.
#[prost(string, tag = "6")]
pub shared_key: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Bucket {
#[prost(string, tag = "1")]
pub endpoint: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub region: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub bucket: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub prefix: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
pub storage_class: ::prost::alloc::string::String,
}
/// CloudDynamic allows testing new cloud providers and new fields without changing protobuf definitions
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CloudDynamic {
#[prost(message, optional, tag = "1")]
pub bucket: ::core::option::Option<Bucket>,
/// s3, gcs and azureBlobStorage are supported
#[prost(string, tag = "2")]
pub provider_name: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "3")]
pub attrs: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
/// HDFS storage backend saves file into HDFS compatible storages
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Hdfs {
/// a URL: hdfs:///some/path or hdfs://host:port/some/path
#[prost(string, tag = "1")]
pub remote: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BackupResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
#[prost(bytes = "vec", tag = "2")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
#[prost(message, repeated, tag = "4")]
pub files: ::prost::alloc::vec::Vec<File>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExternalStorageRestoreRequest {
#[prost(message, optional, tag = "1")]
pub storage_backend: ::core::option::Option<StorageBackend>,
#[prost(string, tag = "2")]
pub object_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub restore_name: ::prost::alloc::string::String,
#[prost(uint64, tag = "4")]
pub content_length: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExternalStorageRestoreResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExternalStorageSaveRequest {
#[prost(message, optional, tag = "1")]
pub storage_backend: ::core::option::Option<StorageBackend>,
#[prost(string, tag = "2")]
pub object_name: ::prost::alloc::string::String,
#[prost(uint64, tag = "3")]
pub content_length: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExternalStorageSaveResponse {}
/// sst files compression algorithm
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum CompressionType {
Unknown = 0,
Lz4 = 1,
Snappy = 2,
Zstd = 3,
}
impl CompressionType {
/// 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 {
CompressionType::Unknown => "UNKNOWN",
CompressionType::Lz4 => "LZ4",
CompressionType::Snappy => "SNAPPY",
CompressionType::Zstd => "ZSTD",
}
}
/// 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),
"LZ4" => Some(Self::Lz4),
"SNAPPY" => Some(Self::Snappy),
"ZSTD" => Some(Self::Zstd),
_ => None,
}
}
}
/// Generated client implementations.
pub mod backup_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct BackupClient<T> {
inner: tonic::client::Grpc<T>,
}
impl BackupClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> BackupClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> BackupClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
BackupClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn backup(
&mut self,
request: impl tonic::IntoRequest<super::BackupRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::BackupResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/backup.Backup/backup");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("backup.Backup", "backup"));
self.inner.server_streaming(req, path, codec).await
}
}
}
/// Generated client implementations.
pub mod external_storage_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// ExternalStorage is a service for using a cloud backend from StorageBackend to store files.
/// This can be used to backup and restore SST files.
#[derive(Debug, Clone)]
pub struct ExternalStorageClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ExternalStorageClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ExternalStorageClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ExternalStorageClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ExternalStorageClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Restore to a file
pub async fn restore(
&mut self,
request: impl tonic::IntoRequest<super::ExternalStorageRestoreRequest>,
) -> std::result::Result<
tonic::Response<super::ExternalStorageRestoreResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/backup.ExternalStorage/restore",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("backup.ExternalStorage", "restore"));
self.inner.unary(req, path, codec).await
}
/// Save a file to storage
pub async fn save(
&mut self,
request: impl tonic::IntoRequest<super::ExternalStorageSaveRequest>,
) -> std::result::Result<
tonic::Response<super::ExternalStorageSaveResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/backup.ExternalStorage/save",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("backup.ExternalStorage", "save"));
self.inner.unary(req, path, codec).await
}
}
}

407
src/generated/cdcpb.rs Normal file
View File

@ -0,0 +1,407 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Header {
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
#[prost(string, tag = "2")]
pub ticdc_version: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DuplicateRequest {
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Compatibility {
#[prost(string, tag = "1")]
pub required_version: ::prost::alloc::string::String,
}
/// ClusterIDMismatch is an error variable that
/// tells people that the cluster ID of the request does not match the TiKV cluster ID.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClusterIdMismatch {
/// The current tikv cluster ID.
#[prost(uint64, tag = "1")]
pub current: u64,
/// The cluster ID of the TiCDC request.
#[prost(uint64, tag = "2")]
pub request: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
#[prost(message, optional, tag = "1")]
pub not_leader: ::core::option::Option<super::errorpb::NotLeader>,
#[prost(message, optional, tag = "2")]
pub region_not_found: ::core::option::Option<super::errorpb::RegionNotFound>,
#[prost(message, optional, tag = "3")]
pub epoch_not_match: ::core::option::Option<super::errorpb::EpochNotMatch>,
#[prost(message, optional, tag = "4")]
pub duplicate_request: ::core::option::Option<DuplicateRequest>,
#[prost(message, optional, tag = "5")]
pub compatibility: ::core::option::Option<Compatibility>,
#[prost(message, optional, tag = "6")]
pub cluster_id_mismatch: ::core::option::Option<ClusterIdMismatch>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxnInfo {
#[prost(uint64, tag = "1")]
pub start_ts: u64,
#[prost(bytes = "vec", tag = "2")]
pub primary: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxnStatus {
#[prost(uint64, tag = "1")]
pub start_ts: u64,
#[prost(uint64, tag = "2")]
pub min_commit_ts: u64,
#[prost(uint64, tag = "3")]
pub commit_ts: u64,
#[prost(bool, tag = "4")]
pub is_rolled_back: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Event {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(uint64, tag = "2")]
pub index: u64,
#[prost(uint64, tag = "7")]
pub request_id: u64,
#[prost(oneof = "event::Event", tags = "3, 4, 5, 6, 8")]
pub event: ::core::option::Option<event::Event>,
}
/// Nested message and enum types in `Event`.
pub mod event {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Row {
#[prost(uint64, tag = "1")]
pub start_ts: u64,
#[prost(uint64, tag = "2")]
pub commit_ts: u64,
#[prost(enumeration = "LogType", tag = "3")]
pub r#type: i32,
#[prost(enumeration = "row::OpType", tag = "4")]
pub op_type: i32,
#[prost(bytes = "vec", tag = "5")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "6")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "7")]
pub old_value: ::prost::alloc::vec::Vec<u8>,
}
/// Nested message and enum types in `Row`.
pub mod row {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum OpType {
Unknown = 0,
Put = 1,
Delete = 2,
}
impl OpType {
/// 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 {
OpType::Unknown => "UNKNOWN",
OpType::Put => "PUT",
OpType::Delete => "DELETE",
}
}
/// 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),
"PUT" => Some(Self::Put),
"DELETE" => Some(Self::Delete),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entries {
#[prost(message, repeated, tag = "1")]
pub entries: ::prost::alloc::vec::Vec<Row>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Admin {
#[prost(message, optional, tag = "1")]
pub admin_request: ::core::option::Option<
super::super::raft_cmdpb::AdminRequest,
>,
#[prost(message, optional, tag = "2")]
pub admin_response: ::core::option::Option<
super::super::raft_cmdpb::AdminResponse,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LongTxn {
#[prost(message, repeated, tag = "1")]
pub txn_info: ::prost::alloc::vec::Vec<super::TxnInfo>,
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum LogType {
Unknown = 0,
Prewrite = 1,
Commit = 2,
Rollback = 3,
Committed = 4,
Initialized = 5,
}
impl LogType {
/// 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 {
LogType::Unknown => "UNKNOWN",
LogType::Prewrite => "PREWRITE",
LogType::Commit => "COMMIT",
LogType::Rollback => "ROLLBACK",
LogType::Committed => "COMMITTED",
LogType::Initialized => "INITIALIZED",
}
}
/// 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),
"PREWRITE" => Some(Self::Prewrite),
"COMMIT" => Some(Self::Commit),
"ROLLBACK" => Some(Self::Rollback),
"COMMITTED" => Some(Self::Committed),
"INITIALIZED" => Some(Self::Initialized),
_ => None,
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Event {
#[prost(message, tag = "3")]
Entries(Entries),
#[prost(message, tag = "4")]
Admin(Admin),
#[prost(message, tag = "5")]
Error(super::Error),
#[prost(uint64, tag = "6")]
ResolvedTs(u64),
/// Note that field 7 is taken by request_id.
///
/// More region level events ...
#[prost(message, tag = "8")]
LongTxn(LongTxn),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChangeDataEvent {
#[prost(message, repeated, tag = "1")]
pub events: ::prost::alloc::vec::Vec<Event>,
/// More store level events ...
#[prost(message, optional, tag = "2")]
pub resolved_ts: ::core::option::Option<ResolvedTs>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResolvedTs {
#[prost(uint64, repeated, tag = "1")]
pub regions: ::prost::alloc::vec::Vec<u64>,
#[prost(uint64, tag = "2")]
pub ts: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChangeDataRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(uint64, tag = "2")]
pub region_id: u64,
#[prost(message, optional, tag = "3")]
pub region_epoch: ::core::option::Option<super::metapb::RegionEpoch>,
#[prost(uint64, tag = "4")]
pub checkpoint_ts: u64,
#[prost(bytes = "vec", tag = "5")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "6")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
/// Used for CDC to identify events corresponding to different requests.
#[prost(uint64, tag = "7")]
pub request_id: u64,
#[prost(enumeration = "super::kvrpcpb::ExtraOp", tag = "8")]
pub extra_op: i32,
#[prost(oneof = "change_data_request::Request", tags = "9, 10")]
pub request: ::core::option::Option<change_data_request::Request>,
}
/// Nested message and enum types in `ChangeDataRequest`.
pub mod change_data_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Register {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NotifyTxnStatus {
#[prost(message, repeated, tag = "1")]
pub txn_status: ::prost::alloc::vec::Vec<super::TxnStatus>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
/// A normal request that trying to register change data feed on a region.
#[prost(message, tag = "9")]
Register(Register),
/// Notify the region that some of the running transactions on the region has a pushed
/// min_commit_ts so that the resolved_ts can be advanced.
#[prost(message, tag = "10")]
NotifyTxnStatus(NotifyTxnStatus),
}
}
/// Generated client implementations.
pub mod change_data_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ChangeDataClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ChangeDataClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ChangeDataClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ChangeDataClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ChangeDataClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn event_feed(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::ChangeDataRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ChangeDataEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/cdcpb.ChangeData/EventFeed",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("cdcpb.ChangeData", "EventFeed"));
self.inner.streaming(req, path, codec).await
}
}
}

407
src/generated/configpb.rs Normal file
View File

@ -0,0 +1,407 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Status {
#[prost(enumeration = "StatusCode", tag = "1")]
pub code: i32,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
/// The version is used to tell the configuration which can be shared
/// or not apart.
/// Global version represents the version of these configuration
/// which can be shared, each kind of component only have one.
/// For local version, every component will have one to represent
/// the version of these configuration which cannot be shared.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Version {
#[prost(uint64, tag = "1")]
pub local: u64,
#[prost(uint64, tag = "2")]
pub global: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Local {
#[prost(string, tag = "1")]
pub component_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Global {
#[prost(string, tag = "1")]
pub component: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfigKind {
#[prost(oneof = "config_kind::Kind", tags = "1, 2")]
pub kind: ::core::option::Option<config_kind::Kind>,
}
/// Nested message and enum types in `ConfigKind`.
pub mod config_kind {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Local(super::Local),
#[prost(message, tag = "2")]
Global(super::Global),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfigEntry {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LocalConfig {
#[prost(message, optional, tag = "1")]
pub version: ::core::option::Option<Version>,
#[prost(string, tag = "2")]
pub component: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub component_id: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub config: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Header {
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub version: ::core::option::Option<Version>,
#[prost(string, tag = "3")]
pub component: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub component_id: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub config: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub status: ::core::option::Option<Status>,
#[prost(message, optional, tag = "3")]
pub version: ::core::option::Option<Version>,
#[prost(string, tag = "4")]
pub config: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAllRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAllResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub status: ::core::option::Option<Status>,
#[prost(message, repeated, tag = "3")]
pub local_configs: ::prost::alloc::vec::Vec<LocalConfig>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub version: ::core::option::Option<Version>,
#[prost(string, tag = "3")]
pub component: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub component_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub status: ::core::option::Option<Status>,
#[prost(message, optional, tag = "3")]
pub version: ::core::option::Option<Version>,
#[prost(string, tag = "4")]
pub config: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub version: ::core::option::Option<Version>,
#[prost(message, optional, tag = "3")]
pub kind: ::core::option::Option<ConfigKind>,
#[prost(message, repeated, tag = "4")]
pub entries: ::prost::alloc::vec::Vec<ConfigEntry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub status: ::core::option::Option<Status>,
#[prost(message, optional, tag = "3")]
pub version: ::core::option::Option<Version>,
#[prost(string, tag = "4")]
pub config: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub version: ::core::option::Option<Version>,
#[prost(message, optional, tag = "3")]
pub kind: ::core::option::Option<ConfigKind>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<Header>,
#[prost(message, optional, tag = "2")]
pub status: ::core::option::Option<Status>,
#[prost(message, optional, tag = "3")]
pub version: ::core::option::Option<Version>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum StatusCode {
Unknown = 0,
Ok = 1,
WrongVersion = 2,
NotChange = 3,
ComponentNotFound = 4,
ComponentIdNotFound = 5,
}
impl StatusCode {
/// 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 {
StatusCode::Unknown => "UNKNOWN",
StatusCode::Ok => "OK",
StatusCode::WrongVersion => "WRONG_VERSION",
StatusCode::NotChange => "NOT_CHANGE",
StatusCode::ComponentNotFound => "COMPONENT_NOT_FOUND",
StatusCode::ComponentIdNotFound => "COMPONENT_ID_NOT_FOUND",
}
}
/// 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),
"OK" => Some(Self::Ok),
"WRONG_VERSION" => Some(Self::WrongVersion),
"NOT_CHANGE" => Some(Self::NotChange),
"COMPONENT_NOT_FOUND" => Some(Self::ComponentNotFound),
"COMPONENT_ID_NOT_FOUND" => Some(Self::ComponentIdNotFound),
_ => None,
}
}
}
/// Generated client implementations.
pub mod config_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ConfigClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ConfigClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ConfigClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ConfigClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ConfigClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn create(
&mut self,
request: impl tonic::IntoRequest<super::CreateRequest>,
) -> std::result::Result<tonic::Response<super::CreateResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/configpb.Config/Create");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("configpb.Config", "Create"));
self.inner.unary(req, path, codec).await
}
pub async fn get_all(
&mut self,
request: impl tonic::IntoRequest<super::GetAllRequest>,
) -> std::result::Result<tonic::Response<super::GetAllResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/configpb.Config/GetAll");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("configpb.Config", "GetAll"));
self.inner.unary(req, path, codec).await
}
pub async fn get(
&mut self,
request: impl tonic::IntoRequest<super::GetRequest>,
) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/configpb.Config/Get");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("configpb.Config", "Get"));
self.inner.unary(req, path, codec).await
}
pub async fn update(
&mut self,
request: impl tonic::IntoRequest<super::UpdateRequest>,
) -> std::result::Result<tonic::Response<super::UpdateResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/configpb.Config/Update");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("configpb.Config", "Update"));
self.inner.unary(req, path, codec).await
}
pub async fn delete(
&mut self,
request: impl tonic::IntoRequest<super::DeleteRequest>,
) -> std::result::Result<tonic::Response<super::DeleteResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/configpb.Config/Delete");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("configpb.Config", "Delete"));
self.inner.unary(req, path, codec).await
}
}
}

View File

@ -0,0 +1,106 @@
/// [start, end)
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyRange {
#[prost(bytes = "vec", tag = "1")]
pub start: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub end: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Request {
#[prost(message, optional, tag = "1")]
pub context: ::core::option::Option<super::kvrpcpb::Context>,
#[prost(int64, tag = "2")]
pub tp: i64,
#[prost(bytes = "vec", tag = "3")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "7")]
pub start_ts: u64,
#[prost(message, repeated, tag = "4")]
pub ranges: ::prost::alloc::vec::Vec<KeyRange>,
/// If cache is enabled, TiKV returns cache hit instead of data if
/// its last version matches this `cache_if_match_version`.
#[prost(bool, tag = "5")]
pub is_cache_enabled: bool,
#[prost(uint64, tag = "6")]
pub cache_if_match_version: u64,
/// Any schema-ful storage to validate schema correctness if necessary.
#[prost(int64, tag = "8")]
pub schema_ver: i64,
#[prost(bool, tag = "9")]
pub is_trace_enabled: bool,
/// paging_size is 0 when it's disabled, otherwise, it should be a positive number.
#[prost(uint64, tag = "10")]
pub paging_size: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Response {
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "2")]
pub region_error: ::core::option::Option<super::errorpb::Error>,
#[prost(message, optional, tag = "3")]
pub locked: ::core::option::Option<super::kvrpcpb::LockInfo>,
#[prost(string, tag = "4")]
pub other_error: ::prost::alloc::string::String,
#[prost(message, optional, tag = "5")]
pub range: ::core::option::Option<KeyRange>,
/// This field is always filled for compatibility consideration. However
/// newer TiDB should respect `exec_details_v2` field instead.
#[prost(message, optional, tag = "6")]
pub exec_details: ::core::option::Option<super::kvrpcpb::ExecDetails>,
/// This field is provided in later versions, containing more detailed
/// information.
#[prost(message, optional, tag = "11")]
pub exec_details_v2: ::core::option::Option<super::kvrpcpb::ExecDetailsV2>,
#[prost(bool, tag = "7")]
pub is_cache_hit: bool,
#[prost(uint64, tag = "8")]
pub cache_last_version: u64,
#[prost(bool, tag = "9")]
pub can_be_cached: bool,
#[prost(message, repeated, tag = "10")]
pub spans: ::prost::alloc::vec::Vec<super::span::SpanSet>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionInfo {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(message, optional, tag = "2")]
pub region_epoch: ::core::option::Option<super::metapb::RegionEpoch>,
#[prost(message, repeated, tag = "3")]
pub ranges: ::prost::alloc::vec::Vec<KeyRange>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchRequest {
#[prost(message, optional, tag = "1")]
pub context: ::core::option::Option<super::kvrpcpb::Context>,
#[prost(int64, tag = "2")]
pub tp: i64,
#[prost(bytes = "vec", tag = "3")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(message, repeated, tag = "4")]
pub regions: ::prost::alloc::vec::Vec<RegionInfo>,
#[prost(uint64, tag = "5")]
pub start_ts: u64,
/// Any schema-ful storage to validate schema correctness if necessary.
#[prost(int64, tag = "6")]
pub schema_ver: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchResponse {
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag = "2")]
pub other_error: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub exec_details: ::core::option::Option<super::kvrpcpb::ExecDetails>,
#[prost(message, repeated, tag = "4")]
pub retry_regions: ::prost::alloc::vec::Vec<super::metapb::Region>,
}

223
src/generated/deadlock.rs Normal file
View File

@ -0,0 +1,223 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WaitForEntriesRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WaitForEntriesResponse {
#[prost(message, repeated, tag = "1")]
pub entries: ::prost::alloc::vec::Vec<WaitForEntry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WaitForEntry {
/// The transaction id that is waiting.
#[prost(uint64, tag = "1")]
pub txn: u64,
/// The transaction id that is being waited for.
#[prost(uint64, tag = "2")]
pub wait_for_txn: u64,
/// The hash value of the key is being waited for.
#[prost(uint64, tag = "3")]
pub key_hash: u64,
/// The key the current txn is trying to lock.
#[prost(bytes = "vec", tag = "4")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// The tag came from the lock request's context.
#[prost(bytes = "vec", tag = "5")]
pub resource_group_tag: ::prost::alloc::vec::Vec<u8>,
/// Milliseconds it has been waits.
#[prost(uint64, tag = "6")]
pub wait_time: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeadlockRequest {
#[prost(enumeration = "DeadlockRequestType", tag = "1")]
pub tp: i32,
#[prost(message, optional, tag = "2")]
pub entry: ::core::option::Option<WaitForEntry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeadlockResponse {
/// The same entry sent by DeadlockRequest, identifies the sender.
#[prost(message, optional, tag = "1")]
pub entry: ::core::option::Option<WaitForEntry>,
/// The key hash of the lock that is hold by the waiting transaction.
#[prost(uint64, tag = "2")]
pub deadlock_key_hash: u64,
/// The other entries of the dead lock circle. The current entry is in `entry` field and not
/// included in this field.
#[prost(message, repeated, tag = "3")]
pub wait_chain: ::prost::alloc::vec::Vec<WaitForEntry>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DeadlockRequestType {
Detect = 0,
/// CleanUpWaitFor cleans a single entry the transaction is waiting.
CleanUpWaitFor = 1,
/// CleanUp cleans all entries the transaction is waiting.
CleanUp = 2,
}
impl DeadlockRequestType {
/// 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 {
DeadlockRequestType::Detect => "Detect",
DeadlockRequestType::CleanUpWaitFor => "CleanUpWaitFor",
DeadlockRequestType::CleanUp => "CleanUp",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Detect" => Some(Self::Detect),
"CleanUpWaitFor" => Some(Self::CleanUpWaitFor),
"CleanUp" => Some(Self::CleanUp),
_ => None,
}
}
}
/// Generated client implementations.
pub mod deadlock_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct DeadlockClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DeadlockClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DeadlockClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> DeadlockClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
DeadlockClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Get local wait for entries, should be handle by every node.
/// The owner should sent this request to all members to build the complete wait for graph.
pub async fn get_wait_for_entries(
&mut self,
request: impl tonic::IntoRequest<super::WaitForEntriesRequest>,
) -> std::result::Result<
tonic::Response<super::WaitForEntriesResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/deadlock.Deadlock/GetWaitForEntries",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("deadlock.Deadlock", "GetWaitForEntries"));
self.inner.unary(req, path, codec).await
}
/// Detect should only sent to the owner. only be handled by the owner.
/// The DeadlockResponse is sent back only if there is deadlock detected.
/// CleanUpWaitFor and CleanUp doesn't return responses.
pub async fn detect(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::DeadlockRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::DeadlockResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/deadlock.Deadlock/Detect");
let mut req = request.into_streaming_request();
req.extensions_mut().insert(GrpcMethod::new("deadlock.Deadlock", "Detect"));
self.inner.streaming(req, path, codec).await
}
}
}

848
src/generated/debugpb.rs Normal file
View File

@ -0,0 +1,848 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRequest {
#[prost(enumeration = "Db", tag = "1")]
pub db: i32,
#[prost(string, tag = "2")]
pub cf: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub key: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetResponse {
#[prost(bytes = "vec", tag = "1")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftLogRequest {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(uint64, tag = "2")]
pub log_index: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftLogResponse {
#[prost(message, optional, tag = "1")]
pub entry: ::core::option::Option<super::eraftpb::Entry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionInfoRequest {
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionInfoResponse {
#[prost(message, optional, tag = "1")]
pub raft_local_state: ::core::option::Option<super::raft_serverpb::RaftLocalState>,
#[prost(message, optional, tag = "2")]
pub raft_apply_state: ::core::option::Option<super::raft_serverpb::RaftApplyState>,
#[prost(message, optional, tag = "3")]
pub region_local_state: ::core::option::Option<
super::raft_serverpb::RegionLocalState,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionSizeRequest {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(string, repeated, tag = "2")]
pub cfs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionSizeResponse {
#[prost(message, repeated, tag = "1")]
pub entries: ::prost::alloc::vec::Vec<region_size_response::Entry>,
}
/// Nested message and enum types in `RegionSizeResponse`.
pub mod region_size_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entry {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub size: u64,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScanMvccRequest {
#[prost(bytes = "vec", tag = "1")]
pub from_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub to_key: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "3")]
pub limit: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScanMvccResponse {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "2")]
pub info: ::core::option::Option<super::kvrpcpb::MvccInfo>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactRequest {
#[prost(enumeration = "Db", tag = "1")]
pub db: i32,
#[prost(string, tag = "2")]
pub cf: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub from_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "4")]
pub to_key: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, tag = "5")]
pub threads: u32,
#[prost(enumeration = "BottommostLevelCompaction", tag = "6")]
pub bottommost_level_compaction: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InjectFailPointRequest {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub actions: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InjectFailPointResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RecoverFailPointRequest {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RecoverFailPointResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListFailPointsRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListFailPointsResponse {
#[prost(message, repeated, tag = "1")]
pub entries: ::prost::alloc::vec::Vec<list_fail_points_response::Entry>,
}
/// Nested message and enum types in `ListFailPointsResponse`.
pub mod list_fail_points_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entry {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub actions: ::prost::alloc::string::String,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetMetricsRequest {
#[prost(bool, tag = "1")]
pub all: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetMetricsResponse {
#[prost(string, tag = "1")]
pub prometheus: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub rocksdb_kv: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub rocksdb_raft: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub jemalloc: ::prost::alloc::string::String,
#[prost(uint64, tag = "5")]
pub store_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionConsistencyCheckRequest {
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionConsistencyCheckResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModifyTikvConfigRequest {
#[prost(enumeration = "Module", tag = "1")]
pub module: i32,
#[prost(string, tag = "2")]
pub config_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub config_value: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModifyTikvConfigResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Property {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRegionPropertiesRequest {
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRegionPropertiesResponse {
#[prost(message, repeated, tag = "1")]
pub props: ::prost::alloc::vec::Vec<Property>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetStoreInfoRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetStoreInfoResponse {
#[prost(uint64, tag = "1")]
pub store_id: u64,
#[prost(enumeration = "super::kvrpcpb::ApiVersion", tag = "2")]
pub api_version: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetClusterInfoRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetClusterInfoResponse {
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAllRegionsInStoreRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAllRegionsInStoreResponse {
#[prost(uint64, repeated, tag = "1")]
pub regions: ::prost::alloc::vec::Vec<u64>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Db {
Invalid = 0,
Kv = 1,
Raft = 2,
}
impl Db {
/// 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 {
Db::Invalid => "INVALID",
Db::Kv => "KV",
Db::Raft => "RAFT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INVALID" => Some(Self::Invalid),
"KV" => Some(Self::Kv),
"RAFT" => Some(Self::Raft),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Module {
Unused = 0,
Kvdb = 1,
Raftdb = 2,
Readpool = 3,
Server = 4,
Storage = 5,
Pd = 6,
Metric = 7,
Coprocessor = 8,
Security = 9,
Import = 10,
}
impl Module {
/// 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 {
Module::Unused => "UNUSED",
Module::Kvdb => "KVDB",
Module::Raftdb => "RAFTDB",
Module::Readpool => "READPOOL",
Module::Server => "SERVER",
Module::Storage => "STORAGE",
Module::Pd => "PD",
Module::Metric => "METRIC",
Module::Coprocessor => "COPROCESSOR",
Module::Security => "SECURITY",
Module::Import => "IMPORT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNUSED" => Some(Self::Unused),
"KVDB" => Some(Self::Kvdb),
"RAFTDB" => Some(Self::Raftdb),
"READPOOL" => Some(Self::Readpool),
"SERVER" => Some(Self::Server),
"STORAGE" => Some(Self::Storage),
"PD" => Some(Self::Pd),
"METRIC" => Some(Self::Metric),
"COPROCESSOR" => Some(Self::Coprocessor),
"SECURITY" => Some(Self::Security),
"IMPORT" => Some(Self::Import),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum BottommostLevelCompaction {
/// Skip bottommost level compaction
Skip = 0,
/// Force bottommost level compaction
Force = 1,
/// Compact bottommost level if there is a compaction filter.
IfHaveCompactionFilter = 2,
}
impl BottommostLevelCompaction {
/// 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 {
BottommostLevelCompaction::Skip => "Skip",
BottommostLevelCompaction::Force => "Force",
BottommostLevelCompaction::IfHaveCompactionFilter => "IfHaveCompactionFilter",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Skip" => Some(Self::Skip),
"Force" => Some(Self::Force),
"IfHaveCompactionFilter" => Some(Self::IfHaveCompactionFilter),
_ => None,
}
}
}
/// Generated client implementations.
pub mod debug_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Debug service for TiKV.
///
/// Errors are defined as follow:
/// - OK: Okay, we are good!
/// - UNKNOWN: For unknown error.
/// - INVALID_ARGUMENT: Something goes wrong within requests.
/// - NOT_FOUND: It is key or region not found, it's based on context, detailed
/// reason can be found in grpc message.
/// Note: It bypasses raft layer.
#[derive(Debug, Clone)]
pub struct DebugClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DebugClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DebugClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> DebugClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
DebugClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Read a value arbitrarily for a key.
/// Note: Server uses key directly w/o any encoding.
pub async fn get(
&mut self,
request: impl tonic::IntoRequest<super::GetRequest>,
) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/Get");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "Get"));
self.inner.unary(req, path, codec).await
}
/// Read raft info.
pub async fn raft_log(
&mut self,
request: impl tonic::IntoRequest<super::RaftLogRequest>,
) -> std::result::Result<
tonic::Response<super::RaftLogResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/RaftLog");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "RaftLog"));
self.inner.unary(req, path, codec).await
}
pub async fn region_info(
&mut self,
request: impl tonic::IntoRequest<super::RegionInfoRequest>,
) -> std::result::Result<
tonic::Response<super::RegionInfoResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/RegionInfo");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "RegionInfo"));
self.inner.unary(req, path, codec).await
}
/// Calculate size of a region.
/// Note: DO NOT CALL IT IN PRODUCTION, it's really expensive.
pub async fn region_size(
&mut self,
request: impl tonic::IntoRequest<super::RegionSizeRequest>,
) -> std::result::Result<
tonic::Response<super::RegionSizeResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/RegionSize");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "RegionSize"));
self.inner.unary(req, path, codec).await
}
/// Scan a specific range.
/// Note: DO NOT CALL IT IN PRODUCTION, it's really expensive.
/// Server uses keys directly w/o any encoding.
pub async fn scan_mvcc(
&mut self,
request: impl tonic::IntoRequest<super::ScanMvccRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ScanMvccResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/ScanMvcc");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "ScanMvcc"));
self.inner.server_streaming(req, path, codec).await
}
/// Compact a column family in a specified range.
/// Note: Server uses keys directly w/o any encoding.
pub async fn compact(
&mut self,
request: impl tonic::IntoRequest<super::CompactRequest>,
) -> std::result::Result<
tonic::Response<super::CompactResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/Compact");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "Compact"));
self.inner.unary(req, path, codec).await
}
/// Inject a fail point. Currently, it's only used in tests.
/// Note: DO NOT CALL IT IN PRODUCTION.
pub async fn inject_fail_point(
&mut self,
request: impl tonic::IntoRequest<super::InjectFailPointRequest>,
) -> std::result::Result<
tonic::Response<super::InjectFailPointResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/InjectFailPoint",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "InjectFailPoint"));
self.inner.unary(req, path, codec).await
}
/// Recover from a fail point.
pub async fn recover_fail_point(
&mut self,
request: impl tonic::IntoRequest<super::RecoverFailPointRequest>,
) -> std::result::Result<
tonic::Response<super::RecoverFailPointResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/RecoverFailPoint",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "RecoverFailPoint"));
self.inner.unary(req, path, codec).await
}
/// List all fail points.
pub async fn list_fail_points(
&mut self,
request: impl tonic::IntoRequest<super::ListFailPointsRequest>,
) -> std::result::Result<
tonic::Response<super::ListFailPointsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/ListFailPoints",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "ListFailPoints"));
self.inner.unary(req, path, codec).await
}
/// Get Metrics
pub async fn get_metrics(
&mut self,
request: impl tonic::IntoRequest<super::GetMetricsRequest>,
) -> std::result::Result<
tonic::Response<super::GetMetricsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/debugpb.Debug/GetMetrics");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("debugpb.Debug", "GetMetrics"));
self.inner.unary(req, path, codec).await
}
/// Do a consistent check for a region.
pub async fn check_region_consistency(
&mut self,
request: impl tonic::IntoRequest<super::RegionConsistencyCheckRequest>,
) -> std::result::Result<
tonic::Response<super::RegionConsistencyCheckResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/CheckRegionConsistency",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "CheckRegionConsistency"));
self.inner.unary(req, path, codec).await
}
/// dynamically modify tikv's config
pub async fn modify_tikv_config(
&mut self,
request: impl tonic::IntoRequest<super::ModifyTikvConfigRequest>,
) -> std::result::Result<
tonic::Response<super::ModifyTikvConfigResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/ModifyTikvConfig",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "ModifyTikvConfig"));
self.inner.unary(req, path, codec).await
}
/// Get region properties
pub async fn get_region_properties(
&mut self,
request: impl tonic::IntoRequest<super::GetRegionPropertiesRequest>,
) -> std::result::Result<
tonic::Response<super::GetRegionPropertiesResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/GetRegionProperties",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "GetRegionProperties"));
self.inner.unary(req, path, codec).await
}
/// Get store ID
pub async fn get_store_info(
&mut self,
request: impl tonic::IntoRequest<super::GetStoreInfoRequest>,
) -> std::result::Result<
tonic::Response<super::GetStoreInfoResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/GetStoreInfo",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "GetStoreInfo"));
self.inner.unary(req, path, codec).await
}
/// Get cluster ID
pub async fn get_cluster_info(
&mut self,
request: impl tonic::IntoRequest<super::GetClusterInfoRequest>,
) -> std::result::Result<
tonic::Response<super::GetClusterInfoResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/GetClusterInfo",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "GetClusterInfo"));
self.inner.unary(req, path, codec).await
}
/// Get all region IDs in the store
pub async fn get_all_regions_in_store(
&mut self,
request: impl tonic::IntoRequest<super::GetAllRegionsInStoreRequest>,
) -> std::result::Result<
tonic::Response<super::GetAllRegionsInStoreResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/debugpb.Debug/GetAllRegionsInStore",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("debugpb.Debug", "GetAllRegionsInStore"));
self.inner.unary(req, path, codec).await
}
}
}

View File

@ -0,0 +1,326 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchLogRequest {
#[prost(int64, tag = "1")]
pub start_time: i64,
#[prost(int64, tag = "2")]
pub end_time: i64,
#[prost(enumeration = "LogLevel", repeated, tag = "3")]
pub levels: ::prost::alloc::vec::Vec<i32>,
/// We use a string array to represent multiple CNF pattern sceniaor like:
/// SELECT * FROM t WHERE c LIKE '%s%' and c REGEXP '.*a.*' because
/// Golang and Rust don't support perl-like (?=re1)(?=re2)
#[prost(string, repeated, tag = "4")]
pub patterns: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(enumeration = "search_log_request::Target", tag = "5")]
pub target: i32,
}
/// Nested message and enum types in `SearchLogRequest`.
pub mod search_log_request {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Target {
Normal = 0,
Slow = 1,
}
impl Target {
/// 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 {
Target::Normal => "Normal",
Target::Slow => "Slow",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Normal" => Some(Self::Normal),
"Slow" => Some(Self::Slow),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchLogResponse {
#[prost(message, repeated, tag = "1")]
pub messages: ::prost::alloc::vec::Vec<LogMessage>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogMessage {
#[prost(int64, tag = "1")]
pub time: i64,
#[prost(enumeration = "LogLevel", tag = "2")]
pub level: i32,
#[prost(string, tag = "3")]
pub message: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerInfoRequest {
#[prost(enumeration = "ServerInfoType", tag = "1")]
pub tp: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerInfoPair {
#[prost(string, tag = "1")]
pub key: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerInfoItem {
/// cpu, memory, disk, network ...
#[prost(string, tag = "1")]
pub tp: ::prost::alloc::string::String,
/// eg. network: lo1/eth0, cpu: core1/core2, disk: sda1/sda2
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
/// all key-value pairs for specified item, e.g:
/// ServerInfoItem {
/// tp = "network"
/// name = "eth0"
/// paris = [
/// ServerInfoPair { key = "readbytes", value = "4k"},
/// ServerInfoPair { key = "writebytes", value = "1k"},
/// ]
/// }
#[prost(message, repeated, tag = "3")]
pub pairs: ::prost::alloc::vec::Vec<ServerInfoPair>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerInfoResponse {
#[prost(message, repeated, tag = "1")]
pub items: ::prost::alloc::vec::Vec<ServerInfoItem>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum LogLevel {
Unknown = 0,
Debug = 1,
Info = 2,
Warn = 3,
Trace = 4,
Critical = 5,
Error = 6,
}
impl LogLevel {
/// 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 {
LogLevel::Unknown => "UNKNOWN",
LogLevel::Debug => "Debug",
LogLevel::Info => "Info",
LogLevel::Warn => "Warn",
LogLevel::Trace => "Trace",
LogLevel::Critical => "Critical",
LogLevel::Error => "Error",
}
}
/// 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),
"Debug" => Some(Self::Debug),
"Info" => Some(Self::Info),
"Warn" => Some(Self::Warn),
"Trace" => Some(Self::Trace),
"Critical" => Some(Self::Critical),
"Error" => Some(Self::Error),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ServerInfoType {
All = 0,
HardwareInfo = 1,
SystemInfo = 2,
LoadInfo = 3,
}
impl ServerInfoType {
/// 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 {
ServerInfoType::All => "All",
ServerInfoType::HardwareInfo => "HardwareInfo",
ServerInfoType::SystemInfo => "SystemInfo",
ServerInfoType::LoadInfo => "LoadInfo",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"All" => Some(Self::All),
"HardwareInfo" => Some(Self::HardwareInfo),
"SystemInfo" => Some(Self::SystemInfo),
"LoadInfo" => Some(Self::LoadInfo),
_ => None,
}
}
}
/// Generated client implementations.
pub mod diagnostics_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Diagnostics service for TiDB cluster components.
#[derive(Debug, Clone)]
pub struct DiagnosticsClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DiagnosticsClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DiagnosticsClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> DiagnosticsClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
DiagnosticsClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Searchs log in the target node
pub async fn search_log(
&mut self,
request: impl tonic::IntoRequest<super::SearchLogRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::SearchLogResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/diagnosticspb.Diagnostics/search_log",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("diagnosticspb.Diagnostics", "search_log"));
self.inner.server_streaming(req, path, codec).await
}
/// Retrieves server info in the target node
pub async fn server_info(
&mut self,
request: impl tonic::IntoRequest<super::ServerInfoRequest>,
) -> std::result::Result<
tonic::Response<super::ServerInfoResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/diagnosticspb.Diagnostics/server_info",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("diagnosticspb.Diagnostics", "server_info"));
self.inner.unary(req, path, codec).await
}
}
}

View File

@ -0,0 +1,29 @@
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DiskUsage {
Normal = 0,
AlmostFull = 1,
AlreadyFull = 2,
}
impl DiskUsage {
/// 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 {
DiskUsage::Normal => "Normal",
DiskUsage::AlmostFull => "AlmostFull",
DiskUsage::AlreadyFull => "AlreadyFull",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Normal" => Some(Self::Normal),
"AlmostFull" => Some(Self::AlmostFull),
"AlreadyFull" => Some(Self::AlreadyFull),
_ => None,
}
}
}

View File

@ -0,0 +1,170 @@
/// General encryption metadata for any data type.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EncryptionMeta {
/// ID of the key used to encrypt the data.
#[prost(uint64, tag = "1")]
pub key_id: u64,
/// Initialization vector (IV) of the data.
#[prost(bytes = "vec", tag = "2")]
pub iv: ::prost::alloc::vec::Vec<u8>,
}
/// Information about an encrypted file.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FileInfo {
/// ID of the key used to encrypt the file.
#[prost(uint64, tag = "1")]
pub key_id: u64,
/// Initialization vector (IV) of the file.
#[prost(bytes = "vec", tag = "2")]
pub iv: ::prost::alloc::vec::Vec<u8>,
/// Method of encryption algorithm used to encrypted the file.
#[prost(enumeration = "EncryptionMethod", tag = "3")]
pub method: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FileDictionary {
/// A map of file name to file info.
#[prost(map = "string, message", tag = "1")]
pub files: ::std::collections::HashMap<::prost::alloc::string::String, FileInfo>,
}
/// The key used to encrypt the user data.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataKey {
/// A sequence of secret bytes used to encrypt data.
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// Method of encryption algorithm used to encrypted data.
#[prost(enumeration = "EncryptionMethod", tag = "2")]
pub method: i32,
/// Creation time of the key.
#[prost(uint64, tag = "3")]
pub creation_time: u64,
/// A flag for the key have ever been exposed.
#[prost(bool, tag = "4")]
pub was_exposed: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyDictionary {
/// A map of key ID to dat key.
#[prost(map = "uint64, message", tag = "1")]
pub keys: ::std::collections::HashMap<u64, DataKey>,
/// ID of a key currently in use.
#[prost(uint64, tag = "2")]
pub current_key_id: u64,
}
/// Master key config.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MasterKey {
#[prost(oneof = "master_key::Backend", tags = "1, 2, 3")]
pub backend: ::core::option::Option<master_key::Backend>,
}
/// Nested message and enum types in `MasterKey`.
pub mod master_key {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Backend {
#[prost(message, tag = "1")]
Plaintext(super::MasterKeyPlaintext),
#[prost(message, tag = "2")]
File(super::MasterKeyFile),
#[prost(message, tag = "3")]
Kms(super::MasterKeyKms),
}
}
/// MasterKeyPlaintext indicates content is stored as plaintext.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MasterKeyPlaintext {}
/// MasterKeyFile is a master key backed by a file containing encryption key in human-readable
/// hex format.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MasterKeyFile {
/// Local file path.
#[prost(string, tag = "1")]
pub path: ::prost::alloc::string::String,
}
/// MasterKeyKms is a master key backed by KMS service that manages the encryption key,
/// and provide API to encrypt and decrypt a data key, which is used to encrypt the content.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MasterKeyKms {
/// KMS vendor.
#[prost(string, tag = "1")]
pub vendor: ::prost::alloc::string::String,
/// KMS key id.
#[prost(string, tag = "2")]
pub key_id: ::prost::alloc::string::String,
/// KMS region.
#[prost(string, tag = "3")]
pub region: ::prost::alloc::string::String,
/// KMS endpoint. Normally not needed.
#[prost(string, tag = "4")]
pub endpoint: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EncryptedContent {
/// Metadata of the encrypted content.
/// Eg. IV, method and KMS key ID
/// It is preferred to define new fields for extra metadata than using this metadata map.
#[prost(map = "string, bytes", tag = "1")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::vec::Vec<u8>,
>,
/// Encrypted content.
#[prost(bytes = "vec", tag = "2")]
pub content: ::prost::alloc::vec::Vec<u8>,
/// Master key used to encrypt the content.
#[prost(message, optional, tag = "3")]
pub master_key: ::core::option::Option<MasterKey>,
/// Initilization vector (IV) used.
#[prost(bytes = "vec", tag = "4")]
pub iv: ::prost::alloc::vec::Vec<u8>,
/// Encrypted data key generated by KMS and used to actually encrypt data.
/// Valid only when KMS is used.
#[prost(bytes = "vec", tag = "5")]
pub ciphertext_key: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EncryptionMethod {
Unknown = 0,
Plaintext = 1,
Aes128Ctr = 2,
Aes192Ctr = 3,
Aes256Ctr = 4,
}
impl EncryptionMethod {
/// 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 {
EncryptionMethod::Unknown => "UNKNOWN",
EncryptionMethod::Plaintext => "PLAINTEXT",
EncryptionMethod::Aes128Ctr => "AES128_CTR",
EncryptionMethod::Aes192Ctr => "AES192_CTR",
EncryptionMethod::Aes256Ctr => "AES256_CTR",
}
}
/// 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),
"PLAINTEXT" => Some(Self::Plaintext),
"AES128_CTR" => Some(Self::Aes128Ctr),
"AES192_CTR" => Some(Self::Aes192Ctr),
"AES256_CTR" => Some(Self::Aes256Ctr),
_ => None,
}
}
}

244
src/generated/enginepb.rs Normal file
View File

@ -0,0 +1,244 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandRequestHeader {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(uint64, tag = "2")]
pub index: u64,
#[prost(uint64, tag = "3")]
pub term: u64,
/// Flush in-memory data to disk.
#[prost(bool, tag = "4")]
pub sync_log: bool,
/// Destroy the region.
#[prost(bool, tag = "5")]
pub destroy: bool,
/// Additional information for the request.
#[prost(bytes = "vec", tag = "6")]
pub context: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<CommandRequestHeader>,
/// kv put / delete
#[prost(message, repeated, tag = "2")]
pub requests: ::prost::alloc::vec::Vec<super::raft_cmdpb::Request>,
/// region metadata manipulation command.
#[prost(message, optional, tag = "3")]
pub admin_request: ::core::option::Option<super::raft_cmdpb::AdminRequest>,
/// region metadata manipulation result.
#[prost(message, optional, tag = "4")]
pub admin_response: ::core::option::Option<super::raft_cmdpb::AdminResponse>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandRequestBatch {
#[prost(message, repeated, tag = "1")]
pub requests: ::prost::alloc::vec::Vec<CommandRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandResponseHeader {
#[prost(uint64, tag = "1")]
pub region_id: u64,
/// Region is destroyed.
#[prost(bool, tag = "2")]
pub destroyed: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<CommandResponseHeader>,
#[prost(message, optional, tag = "2")]
pub apply_state: ::core::option::Option<super::raft_serverpb::RaftApplyState>,
#[prost(uint64, tag = "3")]
pub applied_term: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandResponseBatch {
#[prost(message, repeated, tag = "1")]
pub responses: ::prost::alloc::vec::Vec<CommandResponse>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotState {
#[prost(message, optional, tag = "1")]
pub region: ::core::option::Option<super::metapb::Region>,
#[prost(message, optional, tag = "2")]
pub peer: ::core::option::Option<super::metapb::Peer>,
#[prost(message, optional, tag = "3")]
pub apply_state: ::core::option::Option<super::raft_serverpb::RaftApplyState>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotData {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub checksum: u32,
#[prost(message, repeated, tag = "3")]
pub data: ::prost::alloc::vec::Vec<super::raft_serverpb::KeyValue>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotRequest {
#[prost(oneof = "snapshot_request::Chunk", tags = "1, 2")]
pub chunk: ::core::option::Option<snapshot_request::Chunk>,
}
/// Nested message and enum types in `SnapshotRequest`.
pub mod snapshot_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Chunk {
/// The first message for snapshots.
/// It contains the latest region information after applied snapshot.
#[prost(message, tag = "1")]
State(super::SnapshotState),
/// Following messages are always data.
#[prost(message, tag = "2")]
Data(super::SnapshotData),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotDone {}
/// Generated client implementations.
pub mod engine_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct EngineClient<T> {
inner: tonic::client::Grpc<T>,
}
impl EngineClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> EngineClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> EngineClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
EngineClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn apply_command_batch(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::CommandRequestBatch,
>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::CommandResponseBatch>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/enginepb.Engine/ApplyCommandBatch",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("enginepb.Engine", "ApplyCommandBatch"));
self.inner.streaming(req, path, codec).await
}
pub async fn apply_snapshot(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::SnapshotRequest>,
) -> std::result::Result<tonic::Response<super::SnapshotDone>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/enginepb.Engine/ApplySnapshot",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("enginepb.Engine", "ApplySnapshot"));
self.inner.client_streaming(req, path, codec).await
}
}
}

351
src/generated/eraftpb.rs Normal file
View File

@ -0,0 +1,351 @@
/// The entry is a type of change that needs to be applied. It contains two data fields.
/// While the fields are built into the model; their usage is determined by the entry_type.
///
/// For normal entries, the data field should contain the data change that should be applied.
/// The context field can be used for any contextual data that might be relevant to the
/// application of the data.
///
/// For configuration changes, the data will contain the ConfChange message and the
/// context will provide anything needed to assist the configuration change. The context
/// if for the user to set and use in this case.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entry {
#[prost(enumeration = "EntryType", tag = "1")]
pub entry_type: i32,
#[prost(uint64, tag = "2")]
pub term: u64,
#[prost(uint64, tag = "3")]
pub index: u64,
#[prost(bytes = "vec", tag = "4")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "6")]
pub context: ::prost::alloc::vec::Vec<u8>,
/// Deprecated! It is kept for backward compatibility.
/// TODO: remove it in the next major release.
#[prost(bool, tag = "5")]
pub sync_log: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotMetadata {
/// The current `ConfState`.
#[prost(message, optional, tag = "1")]
pub conf_state: ::core::option::Option<ConfState>,
/// The applied index.
#[prost(uint64, tag = "2")]
pub index: u64,
/// The term of the applied index.
#[prost(uint64, tag = "3")]
pub term: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Snapshot {
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "2")]
pub metadata: ::core::option::Option<SnapshotMetadata>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Message {
#[prost(enumeration = "MessageType", tag = "1")]
pub msg_type: i32,
#[prost(uint64, tag = "2")]
pub to: u64,
#[prost(uint64, tag = "3")]
pub from: u64,
#[prost(uint64, tag = "4")]
pub term: u64,
#[prost(uint64, tag = "5")]
pub log_term: u64,
#[prost(uint64, tag = "6")]
pub index: u64,
#[prost(message, repeated, tag = "7")]
pub entries: ::prost::alloc::vec::Vec<Entry>,
#[prost(uint64, tag = "8")]
pub commit: u64,
#[prost(message, optional, tag = "9")]
pub snapshot: ::core::option::Option<Snapshot>,
#[prost(uint64, tag = "13")]
pub request_snapshot: u64,
#[prost(bool, tag = "10")]
pub reject: bool,
#[prost(uint64, tag = "11")]
pub reject_hint: u64,
#[prost(bytes = "vec", tag = "12")]
pub context: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "14")]
pub priority: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HardState {
#[prost(uint64, tag = "1")]
pub term: u64,
#[prost(uint64, tag = "2")]
pub vote: u64,
#[prost(uint64, tag = "3")]
pub commit: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfState {
#[prost(uint64, repeated, tag = "1")]
pub voters: ::prost::alloc::vec::Vec<u64>,
#[prost(uint64, repeated, tag = "2")]
pub learners: ::prost::alloc::vec::Vec<u64>,
/// The voters in the outgoing config. If not empty the node is in joint consensus.
#[prost(uint64, repeated, tag = "3")]
pub voters_outgoing: ::prost::alloc::vec::Vec<u64>,
/// The nodes that will become learners when the outgoing config is removed.
/// These nodes are necessarily currently in nodes_joint (or they would have
/// been added to the incoming config right away).
#[prost(uint64, repeated, tag = "4")]
pub learners_next: ::prost::alloc::vec::Vec<u64>,
/// If set, the config is joint and Raft will automatically transition into
/// the final config (i.e. remove the outgoing config) when this is safe.
#[prost(bool, tag = "5")]
pub auto_leave: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfChange {
#[prost(enumeration = "ConfChangeType", tag = "2")]
pub change_type: i32,
#[prost(uint64, tag = "3")]
pub node_id: u64,
#[prost(bytes = "vec", tag = "4")]
pub context: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "1")]
pub id: u64,
}
/// ConfChangeSingle is an individual configuration change operation. Multiple
/// such operations can be carried out atomically via a ConfChangeV2.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfChangeSingle {
#[prost(enumeration = "ConfChangeType", tag = "1")]
pub change_type: i32,
#[prost(uint64, tag = "2")]
pub node_id: u64,
}
/// ConfChangeV2 messages initiate configuration changes. They support both the
/// simple "one at a time" membership change protocol and full Joint Consensus
/// allowing for arbitrary changes in membership.
///
/// The supplied context is treated as an opaque payload and can be used to
/// attach an action on the state machine to the application of the config change
/// proposal. Note that contrary to Joint Consensus as outlined in the Raft
/// paper\[1\], configuration changes become active when they are *applied* to the
/// state machine (not when they are appended to the log).
///
/// The simple protocol can be used whenever only a single change is made.
///
/// Non-simple changes require the use of Joint Consensus, for which two
/// configuration changes are run. The first configuration change specifies the
/// desired changes and transitions the Raft group into the joint configuration,
/// in which quorum requires a majority of both the pre-changes and post-changes
/// configuration. Joint Consensus avoids entering fragile intermediate
/// configurations that could compromise survivability. For example, without the
/// use of Joint Consensus and running across three availability zones with a
/// replication factor of three, it is not possible to replace a voter without
/// entering an intermediate configuration that does not survive the outage of
/// one availability zone.
///
/// The provided ConfChangeTransition specifies how (and whether) Joint Consensus
/// is used, and assigns the task of leaving the joint configuration either to
/// Raft or the application. Leaving the joint configuration is accomplished by
/// proposing a ConfChangeV2 with only and optionally the Context field
/// populated.
///
/// For details on Raft membership changes, see:
///
/// \[1\]: <https://github.com/ongardie/dissertation/blob/master/online-trim.pdf>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfChangeV2 {
#[prost(enumeration = "ConfChangeTransition", tag = "1")]
pub transition: i32,
#[prost(message, repeated, tag = "2")]
pub changes: ::prost::alloc::vec::Vec<ConfChangeSingle>,
#[prost(bytes = "vec", tag = "3")]
pub context: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EntryType {
EntryNormal = 0,
EntryConfChange = 1,
EntryConfChangeV2 = 2,
}
impl EntryType {
/// 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 {
EntryType::EntryNormal => "EntryNormal",
EntryType::EntryConfChange => "EntryConfChange",
EntryType::EntryConfChangeV2 => "EntryConfChangeV2",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"EntryNormal" => Some(Self::EntryNormal),
"EntryConfChange" => Some(Self::EntryConfChange),
"EntryConfChangeV2" => Some(Self::EntryConfChangeV2),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MessageType {
MsgHup = 0,
MsgBeat = 1,
MsgPropose = 2,
MsgAppend = 3,
MsgAppendResponse = 4,
MsgRequestVote = 5,
MsgRequestVoteResponse = 6,
MsgSnapshot = 7,
MsgHeartbeat = 8,
MsgHeartbeatResponse = 9,
MsgUnreachable = 10,
MsgSnapStatus = 11,
MsgCheckQuorum = 12,
MsgTransferLeader = 13,
MsgTimeoutNow = 14,
MsgReadIndex = 15,
MsgReadIndexResp = 16,
MsgRequestPreVote = 17,
MsgRequestPreVoteResponse = 18,
}
impl MessageType {
/// 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 {
MessageType::MsgHup => "MsgHup",
MessageType::MsgBeat => "MsgBeat",
MessageType::MsgPropose => "MsgPropose",
MessageType::MsgAppend => "MsgAppend",
MessageType::MsgAppendResponse => "MsgAppendResponse",
MessageType::MsgRequestVote => "MsgRequestVote",
MessageType::MsgRequestVoteResponse => "MsgRequestVoteResponse",
MessageType::MsgSnapshot => "MsgSnapshot",
MessageType::MsgHeartbeat => "MsgHeartbeat",
MessageType::MsgHeartbeatResponse => "MsgHeartbeatResponse",
MessageType::MsgUnreachable => "MsgUnreachable",
MessageType::MsgSnapStatus => "MsgSnapStatus",
MessageType::MsgCheckQuorum => "MsgCheckQuorum",
MessageType::MsgTransferLeader => "MsgTransferLeader",
MessageType::MsgTimeoutNow => "MsgTimeoutNow",
MessageType::MsgReadIndex => "MsgReadIndex",
MessageType::MsgReadIndexResp => "MsgReadIndexResp",
MessageType::MsgRequestPreVote => "MsgRequestPreVote",
MessageType::MsgRequestPreVoteResponse => "MsgRequestPreVoteResponse",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MsgHup" => Some(Self::MsgHup),
"MsgBeat" => Some(Self::MsgBeat),
"MsgPropose" => Some(Self::MsgPropose),
"MsgAppend" => Some(Self::MsgAppend),
"MsgAppendResponse" => Some(Self::MsgAppendResponse),
"MsgRequestVote" => Some(Self::MsgRequestVote),
"MsgRequestVoteResponse" => Some(Self::MsgRequestVoteResponse),
"MsgSnapshot" => Some(Self::MsgSnapshot),
"MsgHeartbeat" => Some(Self::MsgHeartbeat),
"MsgHeartbeatResponse" => Some(Self::MsgHeartbeatResponse),
"MsgUnreachable" => Some(Self::MsgUnreachable),
"MsgSnapStatus" => Some(Self::MsgSnapStatus),
"MsgCheckQuorum" => Some(Self::MsgCheckQuorum),
"MsgTransferLeader" => Some(Self::MsgTransferLeader),
"MsgTimeoutNow" => Some(Self::MsgTimeoutNow),
"MsgReadIndex" => Some(Self::MsgReadIndex),
"MsgReadIndexResp" => Some(Self::MsgReadIndexResp),
"MsgRequestPreVote" => Some(Self::MsgRequestPreVote),
"MsgRequestPreVoteResponse" => Some(Self::MsgRequestPreVoteResponse),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ConfChangeTransition {
/// Automatically use the simple protocol if possible, otherwise fall back
/// to ConfChangeType::Implicit. Most applications will want to use this.
Auto = 0,
/// Use joint consensus unconditionally, and transition out of them
/// automatically (by proposing a zero configuration change).
///
/// This option is suitable for applications that want to minimize the time
/// spent in the joint configuration and do not store the joint configuration
/// in the state machine (outside of InitialState).
Implicit = 1,
/// Use joint consensus and remain in the joint configuration until the
/// application proposes a no-op configuration change. This is suitable for
/// applications that want to explicitly control the transitions, for example
/// to use a custom payload (via the Context field).
Explicit = 2,
}
impl ConfChangeTransition {
/// 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 {
ConfChangeTransition::Auto => "Auto",
ConfChangeTransition::Implicit => "Implicit",
ConfChangeTransition::Explicit => "Explicit",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Auto" => Some(Self::Auto),
"Implicit" => Some(Self::Implicit),
"Explicit" => Some(Self::Explicit),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ConfChangeType {
AddNode = 0,
RemoveNode = 1,
AddLearnerNode = 2,
}
impl ConfChangeType {
/// 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 {
ConfChangeType::AddNode => "AddNode",
ConfChangeType::RemoveNode => "RemoveNode",
ConfChangeType::AddLearnerNode => "AddLearnerNode",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"AddNode" => Some(Self::AddNode),
"RemoveNode" => Some(Self::RemoveNode),
"AddLearnerNode" => Some(Self::AddLearnerNode),
_ => None,
}
}
}

187
src/generated/errorpb.rs Normal file
View File

@ -0,0 +1,187 @@
/// NotLeader is the error variant that tells a request be handle by raft leader
/// is sent to raft follower or learner.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NotLeader {
/// The requested region ID
#[prost(uint64, tag = "1")]
pub region_id: u64,
/// Region leader of the requested region
#[prost(message, optional, tag = "2")]
pub leader: ::core::option::Option<super::metapb::Peer>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DiskFull {
/// The requested store ID
#[prost(uint64, repeated, tag = "1")]
pub store_id: ::prost::alloc::vec::Vec<u64>,
/// The detailed info
#[prost(string, tag = "2")]
pub reason: ::prost::alloc::string::String,
}
/// StoreNotMatch is the error variant that tells the request is sent to wrong store.
/// (i.e. inconsistency of the store ID that request shows and the real store ID of this server.)
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StoreNotMatch {
/// Store id in request
#[prost(uint64, tag = "1")]
pub request_store_id: u64,
/// Actual store id
#[prost(uint64, tag = "2")]
pub actual_store_id: u64,
}
/// RegionNotFound is the error variant that tells there isn't any region in this TiKV
/// matches the requested region ID.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionNotFound {
/// The requested region ID
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
/// RegionNotInitialized is the error variant that tells there isn't any initialized peer
/// matchesthe request region ID.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionNotInitialized {
/// The request region ID
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
/// KeyNotInRegion is the error variant that tells the key the request requires isn't present in
/// this region.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyNotInRegion {
/// The requested key
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// The requested region ID
#[prost(uint64, tag = "2")]
pub region_id: u64,
/// Start key of the requested region
#[prost(bytes = "vec", tag = "3")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
/// Snd key of the requested region
#[prost(bytes = "vec", tag = "4")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
}
/// EpochNotMatch is the error variant that tells a region has been updated.
/// (e.g. by splitting / merging, or raft Confchange.)
/// Hence, a command is based on a stale version of a region.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EpochNotMatch {
/// Available regions that may be siblings of the requested one.
#[prost(message, repeated, tag = "1")]
pub current_regions: ::prost::alloc::vec::Vec<super::metapb::Region>,
}
/// ServerIsBusy is the error variant that tells the server is too busy to response.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerIsBusy {
#[prost(string, tag = "1")]
pub reason: ::prost::alloc::string::String,
/// The suggested backoff time
#[prost(uint64, tag = "2")]
pub backoff_ms: u64,
}
/// StaleCommand is the error variant that tells the command is stale, that is,
/// the current request term is lower than current raft term.
/// This can be retried at most time.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StaleCommand {}
/// RaftEntryTooLarge is the error variant that tells the request is too large to be serialized to a
/// reasonable small raft entry.
/// (i.e. greater than the configured value `raft_entry_max_size` in `raftstore`)
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftEntryTooLarge {
/// The requested region ID
#[prost(uint64, tag = "1")]
pub region_id: u64,
/// Size of the raft entry
#[prost(uint64, tag = "2")]
pub entry_size: u64,
}
/// MaxTimestampNotSynced is the error variant that tells the peer has just become a leader and
/// updating the max timestamp in the concurrency manager from PD TSO is ongoing. In this case,
/// the prewrite of an async commit transaction cannot succeed. The client can backoff and
/// resend the request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MaxTimestampNotSynced {}
/// ReadIndexNotReady is the error variant that tells the read index request is not ready, that is,
/// the current region is in a status that not ready to serve the read index request. For example,
/// region is in splitting or merging status.
/// This can be retried at most time.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadIndexNotReady {
/// The reason why the region is not ready to serve read index request
#[prost(string, tag = "1")]
pub reason: ::prost::alloc::string::String,
/// The requested region ID
#[prost(uint64, tag = "2")]
pub region_id: u64,
}
/// ProposalInMergingMode is the error variant that tells the proposal is rejected because raft is
/// in the merging mode. This may happen when BR/Lightning try to ingest SST.
/// This can be retried at most time.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProposalInMergingMode {
/// The requested region ID
#[prost(uint64, tag = "1")]
pub region_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataIsNotReady {
/// The requested region ID
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(uint64, tag = "2")]
pub peer_id: u64,
#[prost(uint64, tag = "3")]
pub safe_ts: u64,
}
/// Error wraps all region errors, indicates an error encountered by a request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
/// The error message
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub not_leader: ::core::option::Option<NotLeader>,
#[prost(message, optional, tag = "3")]
pub region_not_found: ::core::option::Option<RegionNotFound>,
#[prost(message, optional, tag = "4")]
pub key_not_in_region: ::core::option::Option<KeyNotInRegion>,
#[prost(message, optional, tag = "5")]
pub epoch_not_match: ::core::option::Option<EpochNotMatch>,
#[prost(message, optional, tag = "6")]
pub server_is_busy: ::core::option::Option<ServerIsBusy>,
#[prost(message, optional, tag = "7")]
pub stale_command: ::core::option::Option<StaleCommand>,
#[prost(message, optional, tag = "8")]
pub store_not_match: ::core::option::Option<StoreNotMatch>,
#[prost(message, optional, tag = "9")]
pub raft_entry_too_large: ::core::option::Option<RaftEntryTooLarge>,
#[prost(message, optional, tag = "10")]
pub max_timestamp_not_synced: ::core::option::Option<MaxTimestampNotSynced>,
#[prost(message, optional, tag = "11")]
pub read_index_not_ready: ::core::option::Option<ReadIndexNotReady>,
#[prost(message, optional, tag = "12")]
pub proposal_in_merging_mode: ::core::option::Option<ProposalInMergingMode>,
#[prost(message, optional, tag = "13")]
pub data_is_not_ready: ::core::option::Option<DataIsNotReady>,
#[prost(message, optional, tag = "14")]
pub region_not_initialized: ::core::option::Option<RegionNotInitialized>,
#[prost(message, optional, tag = "15")]
pub disk_full: ::core::option::Option<DiskFull>,
}

379
src/generated/google.api.rs Normal file
View File

@ -0,0 +1,379 @@
/// Defines the HTTP configuration for an API service. It contains a list of
/// \[HttpRule][google.api.HttpRule\], each specifying the mapping of an RPC method
/// to one or more HTTP REST API methods.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Http {
/// A list of HTTP configuration rules that apply to individual API methods.
///
/// **NOTE:** All service configuration rules follow "last one wins" order.
#[prost(message, repeated, tag = "1")]
pub rules: ::prost::alloc::vec::Vec<HttpRule>,
/// When set to true, URL path parameters will be fully URI-decoded except in
/// cases of single segment matches in reserved expansion, where "%2F" will be
/// left encoded.
///
/// The default behavior is to not decode RFC 6570 reserved characters in multi
/// segment matches.
#[prost(bool, tag = "2")]
pub fully_decode_reserved_expansion: bool,
}
/// # gRPC Transcoding
///
/// gRPC Transcoding is a feature for mapping between a gRPC method and one or
/// more HTTP REST endpoints. It allows developers to build a single API service
/// that supports both gRPC APIs and REST APIs. Many systems, including [Google
/// APIs](<https://github.com/googleapis/googleapis>),
/// [Cloud Endpoints](<https://cloud.google.com/endpoints>), [gRPC
/// Gateway](<https://github.com/grpc-ecosystem/grpc-gateway>),
/// and \[Envoy\](<https://github.com/envoyproxy/envoy>) proxy support this feature
/// and use it for large scale production services.
///
/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
/// how different portions of the gRPC request message are mapped to the URL
/// path, URL query parameters, and HTTP request body. It also controls how the
/// gRPC response message is mapped to the HTTP response body. `HttpRule` is
/// typically specified as an `google.api.http` annotation on the gRPC method.
///
/// Each mapping specifies a URL path template and an HTTP method. The path
/// template may refer to one or more fields in the gRPC request message, as long
/// as each field is a non-repeated field with a primitive (non-message) type.
/// The path template controls how fields of the request message are mapped to
/// the URL path.
///
/// Example:
///
/// service Messaging {
/// rpc GetMessage(GetMessageRequest) returns (Message) {
/// option (google.api.http) = {
/// get: "/v1/{name=messages/*}"
/// };
/// }
/// }
/// message GetMessageRequest {
/// string name = 1; // Mapped to URL path.
/// }
/// message Message {
/// string text = 1; // The resource content.
/// }
///
/// This enables an HTTP REST to gRPC mapping as below:
///
/// HTTP | gRPC
/// -----|-----
/// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")`
///
/// Any fields in the request message which are not bound by the path template
/// automatically become HTTP query parameters if there is no HTTP request body.
/// For example:
///
/// service Messaging {
/// rpc GetMessage(GetMessageRequest) returns (Message) {
/// option (google.api.http) = {
/// get:"/v1/messages/{message_id}"
/// };
/// }
/// }
/// message GetMessageRequest {
/// message SubMessage {
/// string subfield = 1;
/// }
/// string message_id = 1; // Mapped to URL path.
/// int64 revision = 2; // Mapped to URL query parameter `revision`.
/// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`.
/// }
///
/// This enables a HTTP JSON to RPC mapping as below:
///
/// HTTP | gRPC
/// -----|-----
/// `GET /v1/messages/123456?revision=2&sub.subfield=foo` |
/// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield:
/// "foo"))`
///
/// Note that fields which are mapped to URL query parameters must have a
/// primitive type or a repeated primitive type or a non-repeated message type.
/// In the case of a repeated type, the parameter can be repeated in the URL
/// as `...?param=A&param=B`. In the case of a message type, each field of the
/// message is mapped to a separate parameter, such as
/// `...?foo.a=A&foo.b=B&foo.c=C`.
///
/// For HTTP methods that allow a request body, the `body` field
/// specifies the mapping. Consider a REST update method on the
/// message resource collection:
///
/// service Messaging {
/// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
/// option (google.api.http) = {
/// patch: "/v1/messages/{message_id}"
/// body: "message"
/// };
/// }
/// }
/// message UpdateMessageRequest {
/// string message_id = 1; // mapped to the URL
/// Message message = 2; // mapped to the body
/// }
///
/// The following HTTP JSON to RPC mapping is enabled, where the
/// representation of the JSON in the request body is determined by
/// protos JSON encoding:
///
/// HTTP | gRPC
/// -----|-----
/// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
/// "123456" message { text: "Hi!" })`
///
/// The special name `*` can be used in the body mapping to define that
/// every field not bound by the path template should be mapped to the
/// request body. This enables the following alternative definition of
/// the update method:
///
/// service Messaging {
/// rpc UpdateMessage(Message) returns (Message) {
/// option (google.api.http) = {
/// patch: "/v1/messages/{message_id}"
/// body: "*"
/// };
/// }
/// }
/// message Message {
/// string message_id = 1;
/// string text = 2;
/// }
///
///
/// The following HTTP JSON to RPC mapping is enabled:
///
/// HTTP | gRPC
/// -----|-----
/// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
/// "123456" text: "Hi!")`
///
/// Note that when using `*` in the body mapping, it is not possible to
/// have HTTP parameters, as all fields not bound by the path end in
/// the body. This makes this option more rarely used in practice when
/// defining REST APIs. The common usage of `*` is in custom methods
/// which don't use the URL at all for transferring data.
///
/// It is possible to define multiple HTTP methods for one RPC by using
/// the `additional_bindings` option. Example:
///
/// service Messaging {
/// rpc GetMessage(GetMessageRequest) returns (Message) {
/// option (google.api.http) = {
/// get: "/v1/messages/{message_id}"
/// additional_bindings {
/// get: "/v1/users/{user_id}/messages/{message_id}"
/// }
/// };
/// }
/// }
/// message GetMessageRequest {
/// string message_id = 1;
/// string user_id = 2;
/// }
///
/// This enables the following two alternative HTTP JSON to RPC mappings:
///
/// HTTP | gRPC
/// -----|-----
/// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
/// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id:
/// "123456")`
///
/// ## Rules for HTTP mapping
///
/// 1. Leaf request fields (recursive expansion nested messages in the request
/// message) are classified into three categories:
/// - Fields referred by the path template. They are passed via the URL path.
/// - Fields referred by the \[HttpRule.body][google.api.HttpRule.body\]. They are passed via the HTTP
/// request body.
/// - All other fields are passed via the URL query parameters, and the
/// parameter name is the field path in the request message. A repeated
/// field can be represented as multiple query parameters under the same
/// name.
/// 2. If \[HttpRule.body][google.api.HttpRule.body\] is "*", there is no URL query parameter, all fields
/// are passed via URL path and HTTP request body.
/// 3. If \[HttpRule.body][google.api.HttpRule.body\] is omitted, there is no HTTP request body, all
/// fields are passed via URL path and URL query parameters.
///
/// ### Path template syntax
///
/// Template = "/" Segments [ Verb ] ;
/// Segments = Segment { "/" Segment } ;
/// Segment = "*" | "**" | LITERAL | Variable ;
/// Variable = "{" FieldPath [ "=" Segments ] "}" ;
/// FieldPath = IDENT { "." IDENT } ;
/// Verb = ":" LITERAL ;
///
/// The syntax `*` matches a single URL path segment. The syntax `**` matches
/// zero or more URL path segments, which must be the last part of the URL path
/// except the `Verb`.
///
/// The syntax `Variable` matches part of the URL path as specified by its
/// template. A variable template must not contain other variables. If a variable
/// matches a single path segment, its template may be omitted, e.g. `{var}`
/// is equivalent to `{var=*}`.
///
/// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`
/// contains any reserved character, such characters should be percent-encoded
/// before the matching.
///
/// If a variable contains exactly one path segment, such as `"{var}"` or
/// `"{var=*}"`, when such a variable is expanded into a URL path on the client
/// side, all characters except `\[-_.~0-9a-zA-Z\]` are percent-encoded. The
/// server side does the reverse decoding. Such variables show up in the
/// [Discovery
/// Document](<https://developers.google.com/discovery/v1/reference/apis>) as
/// `{var}`.
///
/// If a variable contains multiple path segments, such as `"{var=foo/*}"`
/// or `"{var=**}"`, when such a variable is expanded into a URL path on the
/// client side, all characters except `\[-_.~/0-9a-zA-Z\]` are percent-encoded.
/// The server side does the reverse decoding, except "%2F" and "%2f" are left
/// unchanged. Such variables show up in the
/// [Discovery
/// Document](<https://developers.google.com/discovery/v1/reference/apis>) as
/// `{+var}`.
///
/// ## Using gRPC API Service Configuration
///
/// gRPC API Service Configuration (service config) is a configuration language
/// for configuring a gRPC service to become a user-facing product. The
/// service config is simply the YAML representation of the `google.api.Service`
/// proto message.
///
/// As an alternative to annotating your proto file, you can configure gRPC
/// transcoding in your service config YAML files. You do this by specifying a
/// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same
/// effect as the proto annotation. This can be particularly useful if you
/// have a proto that is reused in multiple services. Note that any transcoding
/// specified in the service config will override any matching transcoding
/// configuration in the proto.
///
/// Example:
///
/// http:
/// rules:
/// # Selects a gRPC method and applies HttpRule to it.
/// - selector: example.v1.Messaging.GetMessage
/// get: /v1/messages/{message_id}/{sub.subfield}
///
/// ## Special notes
///
/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
/// proto to JSON conversion must follow the [proto3
/// specification](<https://developers.google.com/protocol-buffers/docs/proto3#json>).
///
/// While the single segment variable follows the semantics of
/// [RFC 6570](<https://tools.ietf.org/html/rfc6570>) Section 3.2.2 Simple String
/// Expansion, the multi segment variable **does not** follow RFC 6570 Section
/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
/// does not expand special characters like `?` and `#`, which would lead
/// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding
/// for multi segment variables.
///
/// The path variables **must not** refer to any repeated or mapped field,
/// because client libraries are not capable of handling such variable expansion.
///
/// The path variables **must not** capture the leading "/" character. The reason
/// is that the most common use case "{var}" does not capture the leading "/"
/// character. For consistency, all path variables must share the same behavior.
///
/// Repeated message fields must not be mapped to URL query parameters, because
/// no client library can support such complicated mapping.
///
/// If an API needs to use a JSON array for request or response body, it can map
/// the request or response body to a repeated field. However, some gRPC
/// Transcoding implementations may not support this feature.
#[cfg(not(doctest))]
#[allow(dead_code)]
pub struct __GoogleApiHttpRuleDocs;
/// HACK: for docs see [`__GoogleApiHttpRuleDocs`]
///
/// this hack allows full doctest pass without failures on examples from that doc
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HttpRule {
/// Selects a method to which this rule applies.
///
/// Refer to \[selector][google.api.DocumentationRule.selector\] for syntax details.
#[prost(string, tag = "1")]
pub selector: ::prost::alloc::string::String,
/// The name of the request field whose value is mapped to the HTTP request
/// body, or `*` for mapping all request fields not captured by the path
/// pattern to the HTTP body, or omitted for not having any HTTP request body.
///
/// NOTE: the referred field must be present at the top-level of the request
/// message type.
#[prost(string, tag = "7")]
pub body: ::prost::alloc::string::String,
/// Optional. The name of the response field whose value is mapped to the HTTP
/// response body. When omitted, the entire response message will be used
/// as the HTTP response body.
///
/// NOTE: The referred field must be present at the top-level of the response
/// message type.
#[prost(string, tag = "12")]
pub response_body: ::prost::alloc::string::String,
/// Additional HTTP bindings for the selector. Nested bindings must
/// not contain an `additional_bindings` field themselves (that is,
/// the nesting may only be one level deep).
#[prost(message, repeated, tag = "11")]
pub additional_bindings: ::prost::alloc::vec::Vec<HttpRule>,
/// Determines the URL pattern is matched by this rules. This pattern can be
/// used with any of the {get|put|post|delete|patch} methods. A custom method
/// can be defined using the 'custom' field.
#[prost(oneof = "http_rule::Pattern", tags = "2, 3, 4, 5, 6, 8")]
pub pattern: ::core::option::Option<http_rule::Pattern>,
}
/// Nested message and enum types in `HttpRule`.
pub mod http_rule {
/// Determines the URL pattern is matched by this rules. This pattern can be
/// used with any of the {get|put|post|delete|patch} methods. A custom method
/// can be defined using the 'custom' field.
#[cfg(not(doctest))]
#[allow(dead_code)]
pub struct __GoogleApiHttpRuleDocs;
/// HACK: for docs see [`__GoogleApiHttpRuleDocs`]
///
/// this hack allows full doctest pass without failures on examples from that doc
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Pattern {
/// Maps to HTTP GET. Used for listing and getting information about
/// resources.
#[prost(string, tag = "2")]
Get(::prost::alloc::string::String),
/// Maps to HTTP PUT. Used for replacing a resource.
#[prost(string, tag = "3")]
Put(::prost::alloc::string::String),
/// Maps to HTTP POST. Used for creating a resource or performing an action.
#[prost(string, tag = "4")]
Post(::prost::alloc::string::String),
/// Maps to HTTP DELETE. Used for deleting a resource.
#[prost(string, tag = "5")]
Delete(::prost::alloc::string::String),
/// Maps to HTTP PATCH. Used for updating a resource.
#[prost(string, tag = "6")]
Patch(::prost::alloc::string::String),
/// The custom pattern is used for specifying an HTTP method that is not
/// included in the `pattern` field, such as HEAD, or "*" to leave the
/// HTTP method unspecified for this rule. The wild-card rule is useful
/// for services that provide content to Web (HTML) clients.
#[prost(message, tag = "8")]
Custom(super::CustomHttpPattern),
}
}
/// A custom pattern is used for defining custom HTTP verb.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CustomHttpPattern {
/// The name of this custom HTTP verb.
#[prost(string, tag = "1")]
pub kind: ::prost::alloc::string::String,
/// The path matched by this custom verb.
#[prost(string, tag = "2")]
pub path: ::prost::alloc::string::String,
}

View File

@ -0,0 +1,572 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SwitchModeRequest {
#[prost(string, tag = "1")]
pub pd_addr: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub request: ::core::option::Option<super::import_sstpb::SwitchModeRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SwitchModeResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OpenEngineRequest {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub key_prefix: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OpenEngineResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteHead {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Mutation {
#[prost(enumeration = "mutation::Op", tag = "1")]
pub op: i32,
#[prost(bytes = "vec", tag = "2")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
/// Nested message and enum types in `Mutation`.
pub mod mutation {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Op {
Put = 0,
}
impl Op {
/// 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 {
Op::Put => "Put",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Put" => Some(Self::Put),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteBatch {
#[prost(uint64, tag = "1")]
pub commit_ts: u64,
#[prost(message, repeated, tag = "2")]
pub mutations: ::prost::alloc::vec::Vec<Mutation>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteEngineRequest {
#[prost(oneof = "write_engine_request::Chunk", tags = "1, 2")]
pub chunk: ::core::option::Option<write_engine_request::Chunk>,
}
/// Nested message and enum types in `WriteEngineRequest`.
pub mod write_engine_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Chunk {
#[prost(message, tag = "1")]
Head(super::WriteHead),
#[prost(message, tag = "2")]
Batch(super::WriteBatch),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KvPair {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteEngineV3Request {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "2")]
pub commit_ts: u64,
#[prost(message, repeated, tag = "3")]
pub pairs: ::prost::alloc::vec::Vec<KvPair>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteEngineResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CloseEngineRequest {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CloseEngineResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImportEngineRequest {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag = "2")]
pub pd_addr: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImportEngineResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CleanupEngineRequest {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CleanupEngineResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactClusterRequest {
#[prost(string, tag = "1")]
pub pd_addr: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub request: ::core::option::Option<super::import_sstpb::CompactRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactClusterResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetVersionRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetVersionResponse {
#[prost(string, tag = "1")]
pub version: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub commit: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetMetricsRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetMetricsResponse {
#[prost(string, tag = "1")]
pub prometheus: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
/// This can happen if the client hasn't opened the engine, or the server
/// restarts while the client is writing or closing. An unclosed engine will
/// be removed on server restart, so the client should not continue but
/// restart the previous job in that case.
#[prost(message, optional, tag = "1")]
pub engine_not_found: ::core::option::Option<error::EngineNotFound>,
}
/// Nested message and enum types in `Error`.
pub mod error {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EngineNotFound {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
}
}
/// Generated client implementations.
pub mod import_kv_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// ImportKV provides a service to import key-value pairs to TiKV.
///
/// In order to import key-value pairs to TiKV, the user should:
/// 1. Open an engine identified by an UUID.
/// 2. Open write streams to write key-value batches to the opened engine.
/// Different streams/clients can write to the same engine concurrently.
/// 3. Close the engine after all write batches have been finished. An
/// engine can only be closed when all write streams are closed. An
/// engine can only be closed once, and it can not be opened again
/// once it is closed.
/// 4. Import the data in the engine to the target cluster. Note that
/// the import process is not atomic, it requires the data to be
/// idempotent on retry. An engine can only be imported after it is
/// closed. An engine can be imported multiple times, but can not be
/// imported concurrently.
/// 5. Clean up the engine after it has been imported. Delete all data
/// in the engine. An engine can not be cleaned up when it is
/// writing or importing.
#[derive(Debug, Clone)]
pub struct ImportKvClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ImportKvClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ImportKvClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ImportKvClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ImportKvClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Switch the target cluster to normal/import mode.
pub async fn switch_mode(
&mut self,
request: impl tonic::IntoRequest<super::SwitchModeRequest>,
) -> std::result::Result<
tonic::Response<super::SwitchModeResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/SwitchMode",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "SwitchMode"));
self.inner.unary(req, path, codec).await
}
/// Open an engine.
pub async fn open_engine(
&mut self,
request: impl tonic::IntoRequest<super::OpenEngineRequest>,
) -> std::result::Result<
tonic::Response<super::OpenEngineResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/OpenEngine",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "OpenEngine"));
self.inner.unary(req, path, codec).await
}
/// Open a write stream to the engine.
pub async fn write_engine(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::WriteEngineRequest,
>,
) -> std::result::Result<
tonic::Response<super::WriteEngineResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/WriteEngine",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "WriteEngine"));
self.inner.client_streaming(req, path, codec).await
}
/// Write to engine, single message version
pub async fn write_engine_v3(
&mut self,
request: impl tonic::IntoRequest<super::WriteEngineV3Request>,
) -> std::result::Result<
tonic::Response<super::WriteEngineResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/WriteEngineV3",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "WriteEngineV3"));
self.inner.unary(req, path, codec).await
}
/// Close the engine.
pub async fn close_engine(
&mut self,
request: impl tonic::IntoRequest<super::CloseEngineRequest>,
) -> std::result::Result<
tonic::Response<super::CloseEngineResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/CloseEngine",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "CloseEngine"));
self.inner.unary(req, path, codec).await
}
/// Import the engine to the target cluster.
pub async fn import_engine(
&mut self,
request: impl tonic::IntoRequest<super::ImportEngineRequest>,
) -> std::result::Result<
tonic::Response<super::ImportEngineResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/ImportEngine",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "ImportEngine"));
self.inner.unary(req, path, codec).await
}
/// Clean up the engine.
pub async fn cleanup_engine(
&mut self,
request: impl tonic::IntoRequest<super::CleanupEngineRequest>,
) -> std::result::Result<
tonic::Response<super::CleanupEngineResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/CleanupEngine",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "CleanupEngine"));
self.inner.unary(req, path, codec).await
}
/// Compact the target cluster for better performance.
pub async fn compact_cluster(
&mut self,
request: impl tonic::IntoRequest<super::CompactClusterRequest>,
) -> std::result::Result<
tonic::Response<super::CompactClusterResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/CompactCluster",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "CompactCluster"));
self.inner.unary(req, path, codec).await
}
/// Get current version and commit hash
pub async fn get_version(
&mut self,
request: impl tonic::IntoRequest<super::GetVersionRequest>,
) -> std::result::Result<
tonic::Response<super::GetVersionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/GetVersion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "GetVersion"));
self.inner.unary(req, path, codec).await
}
/// Get importer metrics
pub async fn get_metrics(
&mut self,
request: impl tonic::IntoRequest<super::GetMetricsRequest>,
) -> std::result::Result<
tonic::Response<super::GetMetricsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_kvpb.ImportKV/GetMetrics",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_kvpb.ImportKV", "GetMetrics"));
self.inner.unary(req, path, codec).await
}
}
}

View File

@ -0,0 +1,730 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SwitchModeRequest {
#[prost(enumeration = "SwitchMode", tag = "1")]
pub mode: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SwitchModeResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Range {
#[prost(bytes = "vec", tag = "1")]
pub start: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub end: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SstMeta {
#[prost(bytes = "vec", tag = "1")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "2")]
pub range: ::core::option::Option<Range>,
#[prost(uint32, tag = "3")]
pub crc32: u32,
#[prost(uint64, tag = "4")]
pub length: u64,
#[prost(string, tag = "5")]
pub cf_name: ::prost::alloc::string::String,
#[prost(uint64, tag = "6")]
pub region_id: u64,
#[prost(message, optional, tag = "7")]
pub region_epoch: ::core::option::Option<super::metapb::RegionEpoch>,
#[prost(bool, tag = "8")]
pub end_key_exclusive: bool,
/// total_kvs and total_bytes is equivalent to PD's approximate_keys and approximate_size
/// set these values can save time from tikv upload keys and size to PD through Heartbeat.
#[prost(uint64, tag = "9")]
pub total_kvs: u64,
#[prost(uint64, tag = "10")]
pub total_bytes: u64,
/// API version implies the encode of the key and value.
#[prost(enumeration = "super::kvrpcpb::ApiVersion", tag = "11")]
pub api_version: i32,
/// cipher_iv is used to encrypt/decrypt sst
#[prost(bytes = "vec", tag = "12")]
pub cipher_iv: ::prost::alloc::vec::Vec<u8>,
}
/// A rewrite rule is applied on the *encoded* keys (the internal storage
/// representation).
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RewriteRule {
#[prost(bytes = "vec", tag = "1")]
pub old_key_prefix: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub new_key_prefix: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "3")]
pub new_timestamp: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UploadRequest {
#[prost(oneof = "upload_request::Chunk", tags = "1, 2")]
pub chunk: ::core::option::Option<upload_request::Chunk>,
}
/// Nested message and enum types in `UploadRequest`.
pub mod upload_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Chunk {
#[prost(message, tag = "1")]
Meta(super::SstMeta),
#[prost(bytes, tag = "2")]
Data(::prost::alloc::vec::Vec<u8>),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UploadResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IngestRequest {
#[prost(message, optional, tag = "1")]
pub context: ::core::option::Option<super::kvrpcpb::Context>,
#[prost(message, optional, tag = "2")]
pub sst: ::core::option::Option<SstMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MultiIngestRequest {
#[prost(message, optional, tag = "1")]
pub context: ::core::option::Option<super::kvrpcpb::Context>,
#[prost(message, repeated, tag = "2")]
pub ssts: ::prost::alloc::vec::Vec<SstMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IngestResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<super::errorpb::Error>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactRequest {
/// Compact files in the range and above the output level.
/// Compact all files if the range is not specified.
/// Compact all files to the bottommost level if the output level is -1.
#[prost(message, optional, tag = "1")]
pub range: ::core::option::Option<Range>,
#[prost(int32, tag = "2")]
pub output_level: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadRequest {
/// The SST meta used to identify the downloaded file.
/// Must be the same among all nodes in the same Raft group.
/// Note: the "crc32" and "cf_name" fields are ignored in this request,
/// and the "range" field represents the closed key range after rewrite
/// (as origin keys in encoded representation).
#[prost(message, optional, tag = "2")]
pub sst: ::core::option::Option<SstMeta>,
/// The file name of the SST file.
#[prost(string, tag = "9")]
pub name: ::prost::alloc::string::String,
/// Performs a key prefix rewrite after downloading the SST file.
/// All keys in the SST will be rewritten as:
///
/// new_key = new_key_prefix + old_key\[len(old_key_prefix)..\]
///
/// When used for TiDB, rewriting the prefix changes the table ID. Please
/// note that key-rewrite is applied on the origin keys in encoded
/// representation (the SST itself should still use data keys in encoded
/// representation).
///
/// You need to ensure that the keys before and after rewriting are in the
/// same order, otherwise the RPC request will fail.
#[prost(message, optional, tag = "13")]
pub rewrite_rule: ::core::option::Option<RewriteRule>,
#[prost(message, optional, tag = "14")]
pub storage_backend: ::core::option::Option<super::backup::StorageBackend>,
#[prost(bool, tag = "15")]
pub is_raw_kv: bool,
/// cipher_info is used to decrypt sst when download sst
#[prost(message, optional, tag = "16")]
pub cipher_info: ::core::option::Option<super::backup::CipherInfo>,
}
/// For now it is just used for distinguishing the error of the request with the error
/// of gRPC, add more concrete types if it is necessary later.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadResponse {
/// The actual key range (after rewrite) of the downloaded SST. The range is
/// inclusive in both ends.
#[prost(message, optional, tag = "1")]
pub range: ::core::option::Option<Range>,
/// Whether the SST is empty. An empty SST is prohibited in TiKV, do not
/// ingest if this field is true.
/// (Deprecated, should be replaced by checking `length == 0` in the future)
#[prost(bool, tag = "2")]
pub is_empty: bool,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
/// The CRC32 checksum of the rewritten SST file (implementation can return
/// zero, indicating the CRC32 was not calculated).
#[prost(uint32, tag = "4")]
pub crc32: u32,
/// The actual length of the rewritten SST file.
#[prost(uint64, tag = "5")]
pub length: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetDownloadSpeedLimitRequest {
/// The download speed limit (bytes/second). Set to 0 for unlimited speed.
#[prost(uint64, tag = "1")]
pub speed_limit: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetDownloadSpeedLimitResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pair {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(enumeration = "pair::Op", tag = "3")]
pub op: i32,
}
/// Nested message and enum types in `Pair`.
pub mod pair {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Op {
Put = 0,
Delete = 1,
}
impl Op {
/// 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 {
Op::Put => "Put",
Op::Delete => "Delete",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Put" => Some(Self::Put),
"Delete" => Some(Self::Delete),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteBatch {
#[prost(uint64, tag = "1")]
pub commit_ts: u64,
#[prost(message, repeated, tag = "2")]
pub pairs: ::prost::alloc::vec::Vec<Pair>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteRequest {
#[prost(oneof = "write_request::Chunk", tags = "1, 2")]
pub chunk: ::core::option::Option<write_request::Chunk>,
}
/// Nested message and enum types in `WriteRequest`.
pub mod write_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Chunk {
#[prost(message, tag = "1")]
Meta(super::SstMeta),
#[prost(message, tag = "2")]
Batch(super::WriteBatch),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
#[prost(message, repeated, tag = "2")]
pub metas: ::prost::alloc::vec::Vec<SstMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RawWriteBatch {
#[prost(uint64, tag = "1")]
pub ttl: u64,
#[prost(message, repeated, tag = "2")]
pub pairs: ::prost::alloc::vec::Vec<Pair>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RawWriteRequest {
#[prost(oneof = "raw_write_request::Chunk", tags = "1, 2")]
pub chunk: ::core::option::Option<raw_write_request::Chunk>,
}
/// Nested message and enum types in `RawWriteRequest`.
pub mod raw_write_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Chunk {
#[prost(message, tag = "1")]
Meta(super::SstMeta),
#[prost(message, tag = "2")]
Batch(super::RawWriteBatch),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RawWriteResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
#[prost(message, repeated, tag = "2")]
pub metas: ::prost::alloc::vec::Vec<SstMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DuplicateDetectRequest {
#[prost(message, optional, tag = "1")]
pub context: ::core::option::Option<super::kvrpcpb::Context>,
#[prost(bytes = "vec", tag = "2")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
/// Return only the keys found by scanning, not their values.
#[prost(bool, tag = "4")]
pub key_only: bool,
/// We only check the data whose timestamp is larger than `min_commit_ts`. `min_commit_ts` is exclueded.
#[prost(uint64, tag = "5")]
pub min_commit_ts: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KvPair {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "3")]
pub commit_ts: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DuplicateDetectResponse {
#[prost(message, optional, tag = "1")]
pub region_error: ::core::option::Option<super::errorpb::Error>,
#[prost(message, optional, tag = "2")]
pub key_error: ::core::option::Option<Error>,
/// The these keys will be in asc order (but commit time is in desc order),
/// and the content is just like following:
/// [
/// {key: "key1", value: "value11", commit_ts: 1005},
/// {key: "key1", value: "value12", commit_ts: 1004},
/// {key: "key1", value: "value13", commit_ts: 1001},
/// {key: "key2", value: "value21", commit_ts: 1004},
/// {key: "key2", value: "value22", commit_ts: 1002},
/// ...
/// ]
#[prost(message, repeated, tag = "3")]
pub pairs: ::prost::alloc::vec::Vec<KvPair>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SwitchMode {
Normal = 0,
Import = 1,
}
impl SwitchMode {
/// 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 {
SwitchMode::Normal => "Normal",
SwitchMode::Import => "Import",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Normal" => Some(Self::Normal),
"Import" => Some(Self::Import),
_ => None,
}
}
}
/// Generated client implementations.
pub mod import_sst_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// ImportSST provides a service to import a generated SST file to a region in TiKV.
///
/// In order to import an SST file to a region, the user should:
/// 1. Retrieve the meta of the region according to the SST file's range.
/// 2. Upload the SST file to the servers where the region's peers locate in.
/// 3. Issue an ingest request to the region's leader with the SST file's metadata.
///
/// It's the user's responsibility to make sure that the SST file is uploaded to
/// the servers where the region's peers locate in, before issue the ingest
/// request to the region's leader. However, the region can be scheduled (so the
/// location of the region's peers will be changed) or split/merged (so the range
/// of the region will be changed), after the SST file is uploaded, but before
/// the SST file is ingested. So, the region's epoch is provided in the SST
/// file's metadata, to guarantee that the region's epoch must be the same
/// between the SST file is uploaded and ingested later.
#[derive(Debug, Clone)]
pub struct ImportSstClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ImportSstClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ImportSstClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ImportSstClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ImportSstClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Switch to normal/import mode.
pub async fn switch_mode(
&mut self,
request: impl tonic::IntoRequest<super::SwitchModeRequest>,
) -> std::result::Result<
tonic::Response<super::SwitchModeResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/SwitchMode",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "SwitchMode"));
self.inner.unary(req, path, codec).await
}
/// Upload an SST file to a server.
pub async fn upload(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::UploadRequest>,
) -> std::result::Result<tonic::Response<super::UploadResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/Upload",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "Upload"));
self.inner.client_streaming(req, path, codec).await
}
/// Ingest an uploaded SST file to a region.
pub async fn ingest(
&mut self,
request: impl tonic::IntoRequest<super::IngestRequest>,
) -> std::result::Result<tonic::Response<super::IngestResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/Ingest",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "Ingest"));
self.inner.unary(req, path, codec).await
}
/// Compact the specific range for better performance.
pub async fn compact(
&mut self,
request: impl tonic::IntoRequest<super::CompactRequest>,
) -> std::result::Result<
tonic::Response<super::CompactResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/Compact",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "Compact"));
self.inner.unary(req, path, codec).await
}
pub async fn set_download_speed_limit(
&mut self,
request: impl tonic::IntoRequest<super::SetDownloadSpeedLimitRequest>,
) -> std::result::Result<
tonic::Response<super::SetDownloadSpeedLimitResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/SetDownloadSpeedLimit",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("import_sstpb.ImportSST", "SetDownloadSpeedLimit"),
);
self.inner.unary(req, path, codec).await
}
/// Download an SST file from an external storage, and performs key-rewrite
/// after downloading.
pub async fn download(
&mut self,
request: impl tonic::IntoRequest<super::DownloadRequest>,
) -> std::result::Result<
tonic::Response<super::DownloadResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/Download",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "Download"));
self.inner.unary(req, path, codec).await
}
/// Open a write stream to generate sst files
pub async fn write(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::WriteRequest>,
) -> std::result::Result<tonic::Response<super::WriteResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/Write",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "Write"));
self.inner.client_streaming(req, path, codec).await
}
pub async fn raw_write(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::RawWriteRequest>,
) -> std::result::Result<
tonic::Response<super::RawWriteResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/RawWrite",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "RawWrite"));
self.inner.client_streaming(req, path, codec).await
}
/// Ingest Multiple files in one request
pub async fn multi_ingest(
&mut self,
request: impl tonic::IntoRequest<super::MultiIngestRequest>,
) -> std::result::Result<tonic::Response<super::IngestResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/MultiIngest",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "MultiIngest"));
self.inner.unary(req, path, codec).await
}
/// Collect duplicate data from TiKV.
pub async fn duplicate_detect(
&mut self,
request: impl tonic::IntoRequest<super::DuplicateDetectRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::DuplicateDetectResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/import_sstpb.ImportSST/DuplicateDetect",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("import_sstpb.ImportSST", "DuplicateDetect"));
self.inner.server_streaming(req, path, codec).await
}
}
}

1885
src/generated/kvrpcpb.rs Normal file

File diff suppressed because it is too large Load Diff

167
src/generated/metapb.rs Normal file
View File

@ -0,0 +1,167 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Cluster {
#[prost(uint64, tag = "1")]
pub id: u64,
/// max peer count for a region.
/// pd will do the auto-balance if region peer count mismatches.
///
/// more attributes......
#[prost(uint32, tag = "2")]
pub max_peer_count: u32,
}
/// Case insensitive key/value for replica constraints.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StoreLabel {
#[prost(string, tag = "1")]
pub key: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Store {
#[prost(uint64, tag = "1")]
pub id: u64,
/// Address to handle client requests (kv, cop, etc.)
#[prost(string, tag = "2")]
pub address: ::prost::alloc::string::String,
#[prost(enumeration = "StoreState", tag = "3")]
pub state: i32,
#[prost(message, repeated, tag = "4")]
pub labels: ::prost::alloc::vec::Vec<StoreLabel>,
#[prost(string, tag = "5")]
pub version: ::prost::alloc::string::String,
/// Address to handle peer requests (raft messages from other store).
/// Empty means same as address.
#[prost(string, tag = "6")]
pub peer_address: ::prost::alloc::string::String,
/// Status address provides the HTTP service for external components
#[prost(string, tag = "7")]
pub status_address: ::prost::alloc::string::String,
#[prost(string, tag = "8")]
pub git_hash: ::prost::alloc::string::String,
/// The start timestamp of the current store
#[prost(int64, tag = "9")]
pub start_timestamp: i64,
#[prost(string, tag = "10")]
pub deploy_path: ::prost::alloc::string::String,
/// The last heartbeat timestamp of the store.
#[prost(int64, tag = "11")]
pub last_heartbeat: i64,
/// If the store is physically destroyed, which means it can never up again.
#[prost(bool, tag = "12")]
pub physically_destroyed: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionEpoch {
/// Conf change version, auto increment when add or remove peer
#[prost(uint64, tag = "1")]
pub conf_ver: u64,
/// Region version, auto increment when split or merge
#[prost(uint64, tag = "2")]
pub version: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Region {
#[prost(uint64, tag = "1")]
pub id: u64,
/// Region key range [start_key, end_key).
#[prost(bytes = "vec", tag = "2")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "4")]
pub region_epoch: ::core::option::Option<RegionEpoch>,
#[prost(message, repeated, tag = "5")]
pub peers: ::prost::alloc::vec::Vec<Peer>,
/// Encryption metadata for start_key and end_key. encryption_meta.iv is IV for start_key.
/// IV for end_key is calculated from (encryption_meta.iv + len(start_key)).
/// The field is only used by PD and should be ignored otherwise.
/// If encryption_meta is empty (i.e. nil), it means start_key and end_key are unencrypted.
#[prost(message, optional, tag = "6")]
pub encryption_meta: ::core::option::Option<super::encryptionpb::EncryptionMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Peer {
#[prost(uint64, tag = "1")]
pub id: u64,
#[prost(uint64, tag = "2")]
pub store_id: u64,
#[prost(enumeration = "PeerRole", tag = "3")]
pub role: i32,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum StoreState {
Up = 0,
Offline = 1,
Tombstone = 2,
}
impl StoreState {
/// 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 {
StoreState::Up => "Up",
StoreState::Offline => "Offline",
StoreState::Tombstone => "Tombstone",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Up" => Some(Self::Up),
"Offline" => Some(Self::Offline),
"Tombstone" => Some(Self::Tombstone),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PeerRole {
/// Voter -> Voter
Voter = 0,
/// Learner/None -> Learner
Learner = 1,
/// Learner/None -> Voter
IncomingVoter = 2,
/// Voter -> Learner
///
/// We forbid Voter -> None, it can introduce unavailability as discussed in
/// etcd-io/etcd#7625
/// Learner -> None can be apply directly, doesn't need to be stored as
/// joint state.
DemotingVoter = 3,
}
impl PeerRole {
/// 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 {
PeerRole::Voter => "Voter",
PeerRole::Learner => "Learner",
PeerRole::IncomingVoter => "IncomingVoter",
PeerRole::DemotingVoter => "DemotingVoter",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Voter" => Some(Self::Voter),
"Learner" => Some(Self::Learner),
"IncomingVoter" => Some(Self::IncomingVoter),
"DemotingVoter" => Some(Self::DemotingVoter),
_ => None,
}
}
}

77
src/generated/mod.rs Normal file
View File

@ -0,0 +1,77 @@
pub mod backup {
include!("backup.rs");
}
pub mod cdcpb {
include!("cdcpb.rs");
}
pub mod configpb {
include!("configpb.rs");
}
pub mod coprocessor {
include!("coprocessor.rs");
}
pub mod deadlock {
include!("deadlock.rs");
}
pub mod debugpb {
include!("debugpb.rs");
}
pub mod diagnosticspb {
include!("diagnosticspb.rs");
}
pub mod disk_usage {
include!("disk_usage.rs");
}
pub mod encryptionpb {
include!("encryptionpb.rs");
}
pub mod enginepb {
include!("enginepb.rs");
}
pub mod eraftpb {
include!("eraftpb.rs");
}
pub mod errorpb {
include!("errorpb.rs");
}
pub mod google {
pub mod api {
include!("google.api.rs");
}
}
pub mod import_kvpb {
include!("import_kvpb.rs");
}
pub mod import_sstpb {
include!("import_sstpb.rs");
}
pub mod kvrpcpb {
include!("kvrpcpb.rs");
}
pub mod metapb {
include!("metapb.rs");
}
pub mod mpp {
include!("mpp.rs");
}
pub mod pdpb {
include!("pdpb.rs");
}
pub mod raft_cmdpb {
include!("raft_cmdpb.rs");
}
pub mod raft_serverpb {
include!("raft_serverpb.rs");
}
pub mod replication_modepb {
include!("replication_modepb.rs");
}
pub mod resource_usage_agent {
include!("resource_usage_agent.rs");
}
pub mod span {
include!("span.rs");
}
pub mod tikvpb {
include!("tikvpb.rs");
}

97
src/generated/mpp.rs Normal file
View File

@ -0,0 +1,97 @@
/// TaskMeta contains meta of a mpp plan, including query's ts and task address.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskMeta {
/// start ts of a query
#[prost(uint64, tag = "1")]
pub start_ts: u64,
/// if task id is -1 , it indicates a tidb task.
#[prost(int64, tag = "2")]
pub task_id: i64,
/// Only used for hash partition
#[prost(int64, tag = "3")]
pub partition_id: i64,
/// target address of this task.
#[prost(string, tag = "4")]
pub address: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IsAliveRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IsAliveResponse {
#[prost(bool, tag = "1")]
pub available: bool,
}
/// Dipsatch the task request to different tiflash servers.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DispatchTaskRequest {
#[prost(message, optional, tag = "1")]
pub meta: ::core::option::Option<TaskMeta>,
#[prost(bytes = "vec", tag = "2")]
pub encoded_plan: ::prost::alloc::vec::Vec<u8>,
#[prost(int64, tag = "3")]
pub timeout: i64,
#[prost(message, repeated, tag = "4")]
pub regions: ::prost::alloc::vec::Vec<super::coprocessor::RegionInfo>,
/// If this task contains table scan, we still need their region info.
#[prost(int64, tag = "5")]
pub schema_ver: i64,
}
/// Get response of DispatchTaskRequest.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DispatchTaskResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
#[prost(message, repeated, tag = "2")]
pub retry_regions: ::prost::alloc::vec::Vec<super::metapb::Region>,
}
/// CancelTaskRequest closes the execution of a task.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CancelTaskRequest {
#[prost(message, optional, tag = "1")]
pub meta: ::core::option::Option<TaskMeta>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CancelTaskResponse {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<Error>,
}
/// build connection between different tasks. Data is sent by the tasks that are closer to the data sources.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EstablishMppConnectionRequest {
/// node closer to the source
#[prost(message, optional, tag = "1")]
pub sender_meta: ::core::option::Option<TaskMeta>,
/// node closer to the tidb mpp gather.
#[prost(message, optional, tag = "2")]
pub receiver_meta: ::core::option::Option<TaskMeta>,
}
/// when TiFlash sends data to TiDB, Data packets wrap tipb.SelectResponse, i.e., serialize tipb.SelectResponse into data;
/// when TiFlash sends data to TiFlash, data blocks are serialized into chunks, and the execution_summaries in tipb.SelectResponse are serialized into data only for the last packet.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MppDataPacket {
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
#[prost(bytes = "vec", repeated, tag = "3")]
pub chunks: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
#[prost(int32, tag = "1")]
pub code: i32,
#[prost(string, tag = "2")]
pub msg: ::prost::alloc::string::String,
}

1866
src/generated/pdpb.rs Normal file

File diff suppressed because it is too large Load Diff

598
src/generated/raft_cmdpb.rs Normal file
View File

@ -0,0 +1,598 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRequest {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub key: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetResponse {
#[prost(bytes = "vec", tag = "1")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PutRequest {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PutResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRequest {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub key: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRangeRequest {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bool, tag = "4")]
pub notify_only: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRangeResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapResponse {
#[prost(message, optional, tag = "1")]
pub region: ::core::option::Option<super::metapb::Region>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PrewriteRequest {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub lock: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PrewriteResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IngestSstRequest {
#[prost(message, optional, tag = "1")]
pub sst: ::core::option::Option<super::import_sstpb::SstMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IngestSstResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadIndexRequest {
/// In replica read, leader uses start_ts and key_ranges to check memory locks.
#[prost(uint64, tag = "1")]
pub start_ts: u64,
#[prost(message, repeated, tag = "2")]
pub key_ranges: ::prost::alloc::vec::Vec<super::kvrpcpb::KeyRange>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadIndexResponse {
#[prost(uint64, tag = "1")]
pub read_index: u64,
/// The memory lock blocking this read at the leader
#[prost(message, optional, tag = "2")]
pub locked: ::core::option::Option<super::kvrpcpb::LockInfo>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Request {
#[prost(enumeration = "CmdType", tag = "1")]
pub cmd_type: i32,
#[prost(message, optional, tag = "2")]
pub get: ::core::option::Option<GetRequest>,
#[prost(message, optional, tag = "4")]
pub put: ::core::option::Option<PutRequest>,
#[prost(message, optional, tag = "5")]
pub delete: ::core::option::Option<DeleteRequest>,
#[prost(message, optional, tag = "6")]
pub snap: ::core::option::Option<SnapRequest>,
#[prost(message, optional, tag = "7")]
pub prewrite: ::core::option::Option<PrewriteRequest>,
#[prost(message, optional, tag = "8")]
pub delete_range: ::core::option::Option<DeleteRangeRequest>,
#[prost(message, optional, tag = "9")]
pub ingest_sst: ::core::option::Option<IngestSstRequest>,
#[prost(message, optional, tag = "10")]
pub read_index: ::core::option::Option<ReadIndexRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Response {
#[prost(enumeration = "CmdType", tag = "1")]
pub cmd_type: i32,
#[prost(message, optional, tag = "2")]
pub get: ::core::option::Option<GetResponse>,
#[prost(message, optional, tag = "4")]
pub put: ::core::option::Option<PutResponse>,
#[prost(message, optional, tag = "5")]
pub delete: ::core::option::Option<DeleteResponse>,
#[prost(message, optional, tag = "6")]
pub snap: ::core::option::Option<SnapResponse>,
#[prost(message, optional, tag = "7")]
pub prewrite: ::core::option::Option<PrewriteResponse>,
#[prost(message, optional, tag = "8")]
pub delte_range: ::core::option::Option<DeleteRangeResponse>,
#[prost(message, optional, tag = "9")]
pub ingest_sst: ::core::option::Option<IngestSstResponse>,
#[prost(message, optional, tag = "10")]
pub read_index: ::core::option::Option<ReadIndexResponse>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChangePeerRequest {
/// This can be only called in internal RaftStore now.
#[prost(enumeration = "super::eraftpb::ConfChangeType", tag = "1")]
pub change_type: i32,
#[prost(message, optional, tag = "2")]
pub peer: ::core::option::Option<super::metapb::Peer>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChangePeerResponse {
#[prost(message, optional, tag = "1")]
pub region: ::core::option::Option<super::metapb::Region>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChangePeerV2Request {
#[prost(message, repeated, tag = "1")]
pub changes: ::prost::alloc::vec::Vec<ChangePeerRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChangePeerV2Response {
#[prost(message, optional, tag = "1")]
pub region: ::core::option::Option<super::metapb::Region>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SplitRequest {
/// This can be only called in internal RaftStore now.
/// The split_key must be in the been splitting region.
#[prost(bytes = "vec", tag = "1")]
pub split_key: ::prost::alloc::vec::Vec<u8>,
/// We split the region into two, first uses the origin
/// parent region id, and the second uses the new_region_id.
/// We must guarantee that the new_region_id is global unique.
#[prost(uint64, tag = "2")]
pub new_region_id: u64,
/// The peer ids for the new split region.
#[prost(uint64, repeated, tag = "3")]
pub new_peer_ids: ::prost::alloc::vec::Vec<u64>,
/// If true, right region derive the origin region_id,
/// left region use new_region_id.
/// Will be ignored in batch split, use `BatchSplitRequest::right_derive` instead.
#[deprecated]
#[prost(bool, tag = "4")]
pub right_derive: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SplitResponse {
#[prost(message, optional, tag = "1")]
pub left: ::core::option::Option<super::metapb::Region>,
#[prost(message, optional, tag = "2")]
pub right: ::core::option::Option<super::metapb::Region>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchSplitRequest {
#[prost(message, repeated, tag = "1")]
pub requests: ::prost::alloc::vec::Vec<SplitRequest>,
/// If true, the last region derive the origin region_id,
/// other regions use new ids.
#[prost(bool, tag = "2")]
pub right_derive: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchSplitResponse {
#[prost(message, repeated, tag = "1")]
pub regions: ::prost::alloc::vec::Vec<super::metapb::Region>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactLogRequest {
#[prost(uint64, tag = "1")]
pub compact_index: u64,
#[prost(uint64, tag = "2")]
pub compact_term: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompactLogResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransferLeaderRequest {
#[prost(message, optional, tag = "1")]
pub peer: ::core::option::Option<super::metapb::Peer>,
#[prost(message, repeated, tag = "2")]
pub peers: ::prost::alloc::vec::Vec<super::metapb::Peer>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransferLeaderResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ComputeHashRequest {
#[prost(bytes = "vec", tag = "1")]
pub context: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerifyHashRequest {
#[prost(uint64, tag = "1")]
pub index: u64,
#[prost(bytes = "vec", tag = "2")]
pub hash: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub context: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerifyHashResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PrepareMergeRequest {
#[prost(uint64, tag = "1")]
pub min_index: u64,
#[prost(message, optional, tag = "2")]
pub target: ::core::option::Option<super::metapb::Region>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PrepareMergeResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommitMergeRequest {
#[prost(message, optional, tag = "1")]
pub source: ::core::option::Option<super::metapb::Region>,
#[prost(uint64, tag = "2")]
pub commit: u64,
#[prost(message, repeated, tag = "3")]
pub entries: ::prost::alloc::vec::Vec<super::eraftpb::Entry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommitMergeResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RollbackMergeRequest {
#[prost(uint64, tag = "1")]
pub commit: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RollbackMergeResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AdminRequest {
#[prost(enumeration = "AdminCmdType", tag = "1")]
pub cmd_type: i32,
#[prost(message, optional, tag = "2")]
pub change_peer: ::core::option::Option<ChangePeerRequest>,
#[deprecated]
#[prost(message, optional, tag = "3")]
pub split: ::core::option::Option<SplitRequest>,
#[prost(message, optional, tag = "4")]
pub compact_log: ::core::option::Option<CompactLogRequest>,
#[prost(message, optional, tag = "5")]
pub transfer_leader: ::core::option::Option<TransferLeaderRequest>,
#[prost(message, optional, tag = "6")]
pub verify_hash: ::core::option::Option<VerifyHashRequest>,
#[prost(message, optional, tag = "7")]
pub prepare_merge: ::core::option::Option<PrepareMergeRequest>,
#[prost(message, optional, tag = "8")]
pub commit_merge: ::core::option::Option<CommitMergeRequest>,
#[prost(message, optional, tag = "9")]
pub rollback_merge: ::core::option::Option<RollbackMergeRequest>,
#[prost(message, optional, tag = "10")]
pub splits: ::core::option::Option<BatchSplitRequest>,
#[prost(message, optional, tag = "11")]
pub change_peer_v2: ::core::option::Option<ChangePeerV2Request>,
#[prost(message, optional, tag = "12")]
pub compute_hash: ::core::option::Option<ComputeHashRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AdminResponse {
#[prost(enumeration = "AdminCmdType", tag = "1")]
pub cmd_type: i32,
#[prost(message, optional, tag = "2")]
pub change_peer: ::core::option::Option<ChangePeerResponse>,
#[deprecated]
#[prost(message, optional, tag = "3")]
pub split: ::core::option::Option<SplitResponse>,
#[prost(message, optional, tag = "4")]
pub compact_log: ::core::option::Option<CompactLogResponse>,
#[prost(message, optional, tag = "5")]
pub transfer_leader: ::core::option::Option<TransferLeaderResponse>,
#[prost(message, optional, tag = "6")]
pub verify_hash: ::core::option::Option<VerifyHashResponse>,
#[prost(message, optional, tag = "7")]
pub prepare_merge: ::core::option::Option<PrepareMergeResponse>,
#[prost(message, optional, tag = "8")]
pub commit_merge: ::core::option::Option<CommitMergeResponse>,
#[prost(message, optional, tag = "9")]
pub rollback_merge: ::core::option::Option<RollbackMergeResponse>,
#[prost(message, optional, tag = "10")]
pub splits: ::core::option::Option<BatchSplitResponse>,
#[prost(message, optional, tag = "11")]
pub change_peer_v2: ::core::option::Option<ChangePeerV2Response>,
}
/// For get the leader of the region.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionLeaderRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionLeaderResponse {
#[prost(message, optional, tag = "1")]
pub leader: ::core::option::Option<super::metapb::Peer>,
}
/// For getting more information of the region.
/// We add some admin operations (ChangePeer, Split...) into the pb job list,
/// then pd server will peek the first one, handle it and then pop it from the job lib.
/// But sometimes, the pd server may crash before popping. When another pd server
/// starts and finds the job is running but not finished, it will first check whether
/// the raft server already has handled this job.
/// E,g, for ChangePeer, if we add Peer10 into region1 and find region1 has already had
/// Peer10, we can think this ChangePeer is finished, and can pop this job from job list
/// directly.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionDetailRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionDetailResponse {
#[prost(message, optional, tag = "1")]
pub region: ::core::option::Option<super::metapb::Region>,
#[prost(message, optional, tag = "2")]
pub leader: ::core::option::Option<super::metapb::Peer>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatusRequest {
#[prost(enumeration = "StatusCmdType", tag = "1")]
pub cmd_type: i32,
#[prost(message, optional, tag = "2")]
pub region_leader: ::core::option::Option<RegionLeaderRequest>,
#[prost(message, optional, tag = "3")]
pub region_detail: ::core::option::Option<RegionDetailRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatusResponse {
#[prost(enumeration = "StatusCmdType", tag = "1")]
pub cmd_type: i32,
#[prost(message, optional, tag = "2")]
pub region_leader: ::core::option::Option<RegionLeaderResponse>,
#[prost(message, optional, tag = "3")]
pub region_detail: ::core::option::Option<RegionDetailResponse>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftRequestHeader {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(message, optional, tag = "2")]
pub peer: ::core::option::Option<super::metapb::Peer>,
/// true for read linearization
#[prost(bool, tag = "3")]
pub read_quorum: bool,
/// 16 bytes, to distinguish request.
#[prost(bytes = "vec", tag = "4")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "5")]
pub region_epoch: ::core::option::Option<super::metapb::RegionEpoch>,
#[prost(uint64, tag = "6")]
pub term: u64,
#[prost(bool, tag = "7")]
pub sync_log: bool,
#[prost(bool, tag = "8")]
pub replica_read: bool,
/// Read requests can be responsed directly after the Raft applys to `applied_index`.
#[prost(uint64, tag = "9")]
pub applied_index: u64,
/// Custom flags for this raft request.
#[prost(uint64, tag = "10")]
pub flags: u64,
#[prost(bytes = "vec", tag = "11")]
pub flag_data: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftResponseHeader {
#[prost(message, optional, tag = "1")]
pub error: ::core::option::Option<super::errorpb::Error>,
#[prost(bytes = "vec", tag = "2")]
pub uuid: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "3")]
pub current_term: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftCmdRequest {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<RaftRequestHeader>,
/// We can't enclose normal requests and administrator request
/// at same time.
#[prost(message, repeated, tag = "2")]
pub requests: ::prost::alloc::vec::Vec<Request>,
#[prost(message, optional, tag = "3")]
pub admin_request: ::core::option::Option<AdminRequest>,
#[prost(message, optional, tag = "4")]
pub status_request: ::core::option::Option<StatusRequest>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftCmdResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<RaftResponseHeader>,
#[prost(message, repeated, tag = "2")]
pub responses: ::prost::alloc::vec::Vec<Response>,
#[prost(message, optional, tag = "3")]
pub admin_response: ::core::option::Option<AdminResponse>,
#[prost(message, optional, tag = "4")]
pub status_response: ::core::option::Option<StatusResponse>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum CmdType {
Invalid = 0,
Get = 1,
Put = 3,
Delete = 4,
Snap = 5,
Prewrite = 6,
DeleteRange = 7,
IngestSst = 8,
ReadIndex = 9,
}
impl CmdType {
/// 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 {
CmdType::Invalid => "Invalid",
CmdType::Get => "Get",
CmdType::Put => "Put",
CmdType::Delete => "Delete",
CmdType::Snap => "Snap",
CmdType::Prewrite => "Prewrite",
CmdType::DeleteRange => "DeleteRange",
CmdType::IngestSst => "IngestSST",
CmdType::ReadIndex => "ReadIndex",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Invalid" => Some(Self::Invalid),
"Get" => Some(Self::Get),
"Put" => Some(Self::Put),
"Delete" => Some(Self::Delete),
"Snap" => Some(Self::Snap),
"Prewrite" => Some(Self::Prewrite),
"DeleteRange" => Some(Self::DeleteRange),
"IngestSST" => Some(Self::IngestSst),
"ReadIndex" => Some(Self::ReadIndex),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum AdminCmdType {
InvalidAdmin = 0,
ChangePeer = 1,
/// Use `BatchSplit` instead.
Split = 2,
CompactLog = 3,
TransferLeader = 4,
ComputeHash = 5,
VerifyHash = 6,
PrepareMerge = 7,
CommitMerge = 8,
RollbackMerge = 9,
BatchSplit = 10,
ChangePeerV2 = 11,
}
impl AdminCmdType {
/// 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 {
AdminCmdType::InvalidAdmin => "InvalidAdmin",
AdminCmdType::ChangePeer => "ChangePeer",
AdminCmdType::Split => "Split",
AdminCmdType::CompactLog => "CompactLog",
AdminCmdType::TransferLeader => "TransferLeader",
AdminCmdType::ComputeHash => "ComputeHash",
AdminCmdType::VerifyHash => "VerifyHash",
AdminCmdType::PrepareMerge => "PrepareMerge",
AdminCmdType::CommitMerge => "CommitMerge",
AdminCmdType::RollbackMerge => "RollbackMerge",
AdminCmdType::BatchSplit => "BatchSplit",
AdminCmdType::ChangePeerV2 => "ChangePeerV2",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"InvalidAdmin" => Some(Self::InvalidAdmin),
"ChangePeer" => Some(Self::ChangePeer),
"Split" => Some(Self::Split),
"CompactLog" => Some(Self::CompactLog),
"TransferLeader" => Some(Self::TransferLeader),
"ComputeHash" => Some(Self::ComputeHash),
"VerifyHash" => Some(Self::VerifyHash),
"PrepareMerge" => Some(Self::PrepareMerge),
"CommitMerge" => Some(Self::CommitMerge),
"RollbackMerge" => Some(Self::RollbackMerge),
"BatchSplit" => Some(Self::BatchSplit),
"ChangePeerV2" => Some(Self::ChangePeerV2),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum StatusCmdType {
InvalidStatus = 0,
RegionLeader = 1,
RegionDetail = 2,
}
impl StatusCmdType {
/// 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 {
StatusCmdType::InvalidStatus => "InvalidStatus",
StatusCmdType::RegionLeader => "RegionLeader",
StatusCmdType::RegionDetail => "RegionDetail",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"InvalidStatus" => Some(Self::InvalidStatus),
"RegionLeader" => Some(Self::RegionLeader),
"RegionDetail" => Some(Self::RegionDetail),
_ => None,
}
}
}

View File

@ -0,0 +1,225 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftMessage {
#[prost(uint64, tag = "1")]
pub region_id: u64,
#[prost(message, optional, tag = "2")]
pub from_peer: ::core::option::Option<super::metapb::Peer>,
#[prost(message, optional, tag = "3")]
pub to_peer: ::core::option::Option<super::metapb::Peer>,
#[prost(message, optional, tag = "4")]
pub message: ::core::option::Option<super::eraftpb::Message>,
#[prost(message, optional, tag = "5")]
pub region_epoch: ::core::option::Option<super::metapb::RegionEpoch>,
/// true means to_peer is a tombstone peer and it should remove itself.
#[prost(bool, tag = "6")]
pub is_tombstone: bool,
/// Region key range [start_key, end_key).
#[prost(bytes = "vec", tag = "7")]
pub start_key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "8")]
pub end_key: ::prost::alloc::vec::Vec<u8>,
/// If it has value, to_peer should be removed if merge is never going to complete.
#[prost(message, optional, tag = "9")]
pub merge_target: ::core::option::Option<super::metapb::Region>,
#[prost(message, optional, tag = "10")]
pub extra_msg: ::core::option::Option<ExtraMessage>,
#[prost(bytes = "vec", tag = "11")]
pub extra_ctx: ::prost::alloc::vec::Vec<u8>,
#[prost(enumeration = "super::disk_usage::DiskUsage", tag = "12")]
pub disk_usage: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftTruncatedState {
#[prost(uint64, tag = "1")]
pub index: u64,
#[prost(uint64, tag = "2")]
pub term: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotCfFile {
#[prost(string, tag = "1")]
pub cf: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub size: u64,
#[prost(uint32, tag = "3")]
pub checksum: u32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotMeta {
#[prost(message, repeated, tag = "1")]
pub cf_files: ::prost::alloc::vec::Vec<SnapshotCfFile>,
/// true means this snapshot is triggered for load balance
#[prost(bool, tag = "2")]
pub for_balance: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnapshotChunk {
#[prost(message, optional, tag = "1")]
pub message: ::core::option::Option<RaftMessage>,
#[prost(bytes = "vec", tag = "2")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Done {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValue {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftSnapshotData {
#[prost(message, optional, tag = "1")]
pub region: ::core::option::Option<super::metapb::Region>,
#[prost(uint64, tag = "2")]
pub file_size: u64,
#[prost(message, repeated, tag = "3")]
pub data: ::prost::alloc::vec::Vec<KeyValue>,
#[prost(uint64, tag = "4")]
pub version: u64,
#[prost(message, optional, tag = "5")]
pub meta: ::core::option::Option<SnapshotMeta>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StoreIdent {
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
#[prost(uint64, tag = "2")]
pub store_id: u64,
#[prost(enumeration = "super::kvrpcpb::ApiVersion", tag = "3")]
pub api_version: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftLocalState {
#[prost(message, optional, tag = "1")]
pub hard_state: ::core::option::Option<super::eraftpb::HardState>,
#[prost(uint64, tag = "2")]
pub last_index: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RaftApplyState {
#[prost(uint64, tag = "1")]
pub applied_index: u64,
#[prost(uint64, tag = "3")]
pub last_commit_index: u64,
#[prost(uint64, tag = "4")]
pub commit_index: u64,
#[prost(uint64, tag = "5")]
pub commit_term: u64,
#[prost(message, optional, tag = "2")]
pub truncated_state: ::core::option::Option<RaftTruncatedState>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MergeState {
#[prost(uint64, tag = "1")]
pub min_index: u64,
#[prost(message, optional, tag = "2")]
pub target: ::core::option::Option<super::metapb::Region>,
#[prost(uint64, tag = "3")]
pub commit: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegionLocalState {
#[prost(enumeration = "PeerState", tag = "1")]
pub state: i32,
#[prost(message, optional, tag = "2")]
pub region: ::core::option::Option<super::metapb::Region>,
#[prost(message, optional, tag = "3")]
pub merge_state: ::core::option::Option<MergeState>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExtraMessage {
#[prost(enumeration = "ExtraMessageType", tag = "1")]
pub r#type: i32,
#[prost(uint64, tag = "2")]
pub premerge_commit: u64,
#[prost(message, repeated, tag = "3")]
pub check_peers: ::prost::alloc::vec::Vec<super::metapb::Peer>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PeerState {
Normal = 0,
Applying = 1,
Tombstone = 2,
Merging = 3,
}
impl PeerState {
/// 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 {
PeerState::Normal => "Normal",
PeerState::Applying => "Applying",
PeerState::Tombstone => "Tombstone",
PeerState::Merging => "Merging",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Normal" => Some(Self::Normal),
"Applying" => Some(Self::Applying),
"Tombstone" => Some(Self::Tombstone),
"Merging" => Some(Self::Merging),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ExtraMessageType {
MsgRegionWakeUp = 0,
MsgWantRollbackMerge = 1,
MsgCheckStalePeer = 2,
MsgCheckStalePeerResponse = 3,
/// If leader is going to sleep, it will send requests to all its followers
/// to make sure they all agree to sleep.
MsgHibernateRequest = 4,
MsgHibernateResponse = 5,
}
impl ExtraMessageType {
/// 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 {
ExtraMessageType::MsgRegionWakeUp => "MsgRegionWakeUp",
ExtraMessageType::MsgWantRollbackMerge => "MsgWantRollbackMerge",
ExtraMessageType::MsgCheckStalePeer => "MsgCheckStalePeer",
ExtraMessageType::MsgCheckStalePeerResponse => "MsgCheckStalePeerResponse",
ExtraMessageType::MsgHibernateRequest => "MsgHibernateRequest",
ExtraMessageType::MsgHibernateResponse => "MsgHibernateResponse",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MsgRegionWakeUp" => Some(Self::MsgRegionWakeUp),
"MsgWantRollbackMerge" => Some(Self::MsgWantRollbackMerge),
"MsgCheckStalePeer" => Some(Self::MsgCheckStalePeer),
"MsgCheckStalePeerResponse" => Some(Self::MsgCheckStalePeerResponse),
"MsgHibernateRequest" => Some(Self::MsgHibernateRequest),
"MsgHibernateResponse" => Some(Self::MsgHibernateResponse),
_ => None,
}
}
}

View File

@ -0,0 +1,127 @@
/// 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,
}
}
}

View File

@ -0,0 +1,305 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CpuTimeRecord {
#[prost(bytes = "vec", tag = "1")]
pub resource_group_tag: ::prost::alloc::vec::Vec<u8>,
/// UNIX timestamp in second.
#[prost(uint64, repeated, tag = "2")]
pub record_list_timestamp_sec: ::prost::alloc::vec::Vec<u64>,
/// The value can be greater than 1000ms if the requests are running parallelly.
#[prost(uint32, repeated, tag = "3")]
pub record_list_cpu_time_ms: ::prost::alloc::vec::Vec<u32>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceUsageRecord {
#[prost(bytes = "vec", tag = "1")]
pub resource_group_tag: ::prost::alloc::vec::Vec<u8>,
/// UNIX timestamp in second.
#[prost(uint64, repeated, tag = "2")]
pub record_list_timestamp_sec: ::prost::alloc::vec::Vec<u64>,
/// The value can be greater than 1000ms if the requests are running parallelly.
#[prost(uint32, repeated, tag = "3")]
pub record_list_cpu_time_ms: ::prost::alloc::vec::Vec<u32>,
/// The number of reads of keys associated with resource_group_tag.
#[prost(uint32, repeated, tag = "4")]
pub record_list_read_keys: ::prost::alloc::vec::Vec<u32>,
/// The number of writes of keys associated with resource_group_tag.
#[prost(uint32, repeated, tag = "5")]
pub record_list_write_keys: ::prost::alloc::vec::Vec<u32>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmptyResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceMeteringRequest {}
/// Generated client implementations.
pub mod resource_usage_agent_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// ResourceUsageAgent is the service for storing resource usage records.
#[derive(Debug, Clone)]
pub struct ResourceUsageAgentClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ResourceUsageAgentClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ResourceUsageAgentClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ResourceUsageAgentClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ResourceUsageAgentClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// DEPRECATED: We now use `Report` to report not only CPU time.
///
/// Report the CPU time records. By default, the records with the same
/// resource group tag will be batched by minute.
pub async fn report_cpu_time(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::CpuTimeRecord>,
) -> std::result::Result<tonic::Response<super::EmptyResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/resource_usage_agent.ResourceUsageAgent/ReportCPUTime",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"resource_usage_agent.ResourceUsageAgent",
"ReportCPUTime",
),
);
self.inner.client_streaming(req, path, codec).await
}
/// Report the resource usage records. By default, the records with the same
/// resource group tag will be batched by minute.
pub async fn report(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::ResourceUsageRecord,
>,
) -> std::result::Result<tonic::Response<super::EmptyResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/resource_usage_agent.ResourceUsageAgent/Report",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(
GrpcMethod::new("resource_usage_agent.ResourceUsageAgent", "Report"),
);
self.inner.client_streaming(req, path, codec).await
}
}
}
/// Generated client implementations.
pub mod resource_metering_pub_sub_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// TiKV implements ResourceMeteringPubSub service for clients to subscribe to resource metering records.
#[derive(Debug, Clone)]
pub struct ResourceMeteringPubSubClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ResourceMeteringPubSubClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ResourceMeteringPubSubClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ResourceMeteringPubSubClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
ResourceMeteringPubSubClient::new(
InterceptedService::new(inner, interceptor),
)
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Clients subscribe to resource metering records through this RPC, and TiKV periodically (e.g. per minute)
/// publishes resource metering records to clients via gRPC stream.
pub async fn subscribe(
&mut self,
request: impl tonic::IntoRequest<super::ResourceMeteringRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ResourceUsageRecord>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/resource_usage_agent.ResourceMeteringPubSub/Subscribe",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"resource_usage_agent.ResourceMeteringPubSub",
"Subscribe",
),
);
self.inner.server_streaming(req, path, codec).await
}
}
}

60
src/generated/span.rs Normal file
View File

@ -0,0 +1,60 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SpanSet {
#[prost(uint64, tag = "1")]
pub start_time_ns: u64,
#[prost(uint64, tag = "2")]
pub cycles_per_sec: u64,
#[prost(message, repeated, tag = "3")]
pub spans: ::prost::alloc::vec::Vec<Span>,
#[prost(uint64, tag = "4")]
pub create_time_ns: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Root {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Parent {
#[prost(uint64, tag = "1")]
pub id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Continue {
#[prost(uint64, tag = "1")]
pub id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Link {
#[prost(oneof = "link::Link", tags = "1, 2, 3")]
pub link: ::core::option::Option<link::Link>,
}
/// Nested message and enum types in `Link`.
pub mod link {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Link {
#[prost(message, tag = "1")]
Root(super::Root),
#[prost(message, tag = "2")]
Parent(super::Parent),
#[prost(message, tag = "3")]
Continue(super::Continue),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Span {
#[prost(uint64, tag = "1")]
pub id: u64,
#[prost(message, optional, tag = "2")]
pub link: ::core::option::Option<Link>,
#[prost(uint64, tag = "3")]
pub begin_cycles: u64,
#[prost(uint64, tag = "4")]
pub end_cycles: u64,
#[prost(uint32, tag = "5")]
pub event: u32,
}

1595
src/generated/tikvpb.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -90,8 +90,6 @@
//! # })}
//! ```
// To support both prost & rust-protobuf.
#![cfg_attr(feature = "prost-codec", allow(clippy::useless_conversion))]
#![allow(clippy::field_reassign_with_default)]
pub mod backoff;

View File

@ -6,5 +6,5 @@
pub use protos::*;
mod protos {
include!(concat!(env!("OUT_DIR"), "/mod.rs"));
include!("generated/mod.rs");
}