Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TiKV as a data store backend #15

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/config/schema/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Builder<Schemas, ()> {
.source_filter_if_eq(
"type",
["internal"],
&["foundationdb", "mysql", "postgresql", "sqlite", "rocksdb"],
&["foundationdb", "mysql", "postgresql", "sqlite", "rocksdb", "tikv"],
)
.source_filter_if_eq("type", ["sql"], &["mysql", "postgresql", "sqlite"])
.input_check([], [Validator::Required])
Expand Down
5 changes: 4 additions & 1 deletion src/pages/config/schema/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Builder<Schemas, ()> {
},
typ: SelectType::Single,
})
.source_filter(&["foundationdb", "mysql", "postgresql", "sqlite", "rocksdb"])
.source_filter(&["foundationdb", "mysql", "postgresql", "sqlite", "rocksdb", "tikv"])
.input_check([], [Validator::Required])
.build()
.new_field("storage.blob")
Expand All @@ -47,6 +47,7 @@ impl Builder<Schemas, ()> {
"postgresql",
"sqlite",
"rocksdb",
"tikv",
"s3",
"fs",
])
Expand All @@ -72,6 +73,7 @@ impl Builder<Schemas, ()> {
"postgresql",
"sqlite",
"rocksdb",
"tikv",
"elasticsearch",
])
.input_check([], [Validator::Required])
Expand All @@ -96,6 +98,7 @@ impl Builder<Schemas, ()> {
"postgresql",
"sqlite",
"rocksdb",
"tikv",
"redis",
])
.input_check([], [Validator::Required])
Expand Down
105 changes: 101 additions & 4 deletions src/pages/config/schema/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl Builder<Schemas, ()> {
("postgresql", "PostgreSQL"),
("mysql", "mySQL"),
("sqlite", "SQLite"),
("tikv", "TiKV"),
("s3", "S3-compatible"),
("redis", "Redis/Memcached"),
("elasticsearch", "ElasticSearch"),
Expand Down Expand Up @@ -218,7 +219,7 @@ impl Builder<Schemas, ()> {
.new_field("tls.enable")
.label("Enable TLS")
.help("Use TLS to connect to the store")
.display_if_eq("type", ["postgresql", "mysql"])
.display_if_eq("type", ["postgresql", "mysql", "tikv"])
.default("false")
.typ(Type::Boolean)
.build()
Expand All @@ -229,6 +230,24 @@ impl Builder<Schemas, ()> {
.default("false")
.typ(Type::Boolean)
.build()
.new_field("tls.root-ca-path")
.label("Root Certificate Path")
.help("Path to the root certificate file in PEM format")
.display_if_eq("tls.enable", ["true"])
.input_check([Transformer::Trim], [Validator::Required])
.build()
.new_field("tls.pub-cert-path")
.label("Public Certificate Path")
.help("Path to the public certificate file in PEM format")
.display_if_eq("tls.enable", ["true"])
.input_check([Transformer::Trim], [Validator::Required])
.build()
.new_field("tls.priv-key-path")
.label("Private Key Path")
.help("Path to the private key file in PEM format")
.display_if_eq("tls.enable", ["true"])
.input_check([Transformer::Trim], [Validator::Required])
.build()
// URL
.new_field("url")
.label("URL")
Expand Down Expand Up @@ -334,7 +353,7 @@ impl Builder<Schemas, ()> {
.placeholder("1s")
.typ(Type::Duration)
.new_field("transaction.retry-limit")
.label("Retry limit")
.label("Retry Limit")
.help("Transaction retry limit")
.placeholder("10")
.typ(Type::Input)
Expand Down Expand Up @@ -371,6 +390,72 @@ impl Builder<Schemas, ()> {
],
)
.build()
// TiKV specific
.new_field("pd-endpoints")
.label("PD Endpoints")
.help("Socket addresses of Placement Drivers (not the TiKV nodes)")
.display_if_eq("type", ["tikv"])
.typ(Type::Array)
.input_check_if_eq("tls.enable", ["true"], [Transformer::Trim], [Validator::Required, Validator::IsUrl])
.input_check([Transformer::Trim], [Validator::Required, Validator::IsSocketAddr])
.build()
.new_field("transaction.timeout")
.display_if_eq("type", ["tikv"])
.label("Timeout")
.help("Transaction timeout with the default being 2 seconds")
.placeholder("2s")
.default("2s")
.typ(Type::Duration)
.new_field("transaction.backoff-type")
.label("Backoff type")
.help("Type of backoff and the delay jitter algorithm if enabled")
.default_if_eq("type", ["tikv"],"full-jitter")
.typ(Type::Select {
source: Source::Static(&[
("none", "None"),
("expo-jitter", "With exponential jitter"),
("full-jitter", "With full jitter"),
("equal-jitter", "With equal jitter"),
("decor-jitter", "With decorrelated jitter")
]),
typ: SelectType::Single,
})
.build()
.new_field("transaction.backoff-min-delay")
.label("Max Retry Delay")
.help("Transaction backoff base retry delay")
.display_if_eq("transaction.backoff-type",
["expo-jitter", "full-jitter", "equal-jitter", "decor-jitter"])
.default("2ms")
.typ(Type::Duration)
.input_check(
[],
[Validator::Required],
)
.new_field("transaction.backoff-max-delay")
.label("Max Retry Delay")
.help("Transaction backoff maximum retry delay")
.default("2ms")
.typ(Type::Duration)
.input_check(
[],
[Validator::Required],
)
.new_field("transaction.backoff-retry-limit")
.label("Retry Limit")
.help("Maximum backoff retry retry limit")
.placeholder("10")
.default("10")
.typ(Type::Input)
.input_check(
[Transformer::Trim],
[
Validator::Required,
Validator::MinValue(1.into()),
Validator::MaxValue(1000.into()),
],
)
.build()
// ElasticSearch specific
.new_field("cloud-id")
.label("Cloud Id")
Expand Down Expand Up @@ -515,6 +600,7 @@ impl Builder<Schemas, ()> {
"cloud-id",
"profile",
"timeout",
"pd-endpoints",
])
.build()
.new_form_section()
Expand Down Expand Up @@ -544,6 +630,7 @@ impl Builder<Schemas, ()> {
"sqlite",
"rocksdb",
"foundationdb",
"tikv",
"fs",
"s3",
],
Expand All @@ -559,7 +646,13 @@ impl Builder<Schemas, ()> {
.new_form_section()
.title("TLS")
.display_if_eq("type", ["postgresql", "mysql", "elasticsearch"])
.fields(["tls.enable", "tls.allow-invalid-certs"])
.fields(["tls.enable", "tls.allow-invalid-certs", "tls.root-ca-path", "tls.pub-cert-path", "tls.priv-key-path"])
.build()
// TiKV specific
.new_form_section()
.title("TLS")
.display_if_eq("type", ["tikv"])
.fields(["tls.enable", "tls.root-ca-path", "tls.pub-cert-path", "tls.priv-key-path"])
.build()
.new_form_section()
.title("Pools")
Expand Down Expand Up @@ -587,11 +680,15 @@ impl Builder<Schemas, ()> {
.build()
.new_form_section()
.title("Transaction Settings")
.display_if_eq("type", ["foundationdb"])
.display_if_eq("type", ["foundationdb", "tikv"])
.fields([
"transaction.timeout",
"transaction.max-retry-delay",
"transaction.retry-limit",
"transaction.backoff-type",
"transaction.backoff-min-delay",
"transaction.backoff-max-delay",
"transaction.backoff-retry-limit",
])
.build()
.new_form_section()
Expand Down