mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
feat: make the gRPC channel between Frontend and Datanode configurable (#2044)
* feat: expose frontend datanode_client_options * chore: add configuration options to the configuration file * refactor(frontend): extract DatanodeOptions to service_config * refactor(frontend): extract DatanodeOptions to service_config * style: remove unnecessary suffix in variable name Co-authored-by: Yingwen <realevenyag@gmail.com> * feat: use humantime_serde for readable duration --------- Co-authored-by: Yingwen <realevenyag@gmail.com>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3284,6 +3284,7 @@ dependencies = [
|
||||
"file-table-engine",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"humantime-serde",
|
||||
"itertools 0.10.5",
|
||||
"meta-client",
|
||||
"meta-srv",
|
||||
|
||||
@@ -70,3 +70,11 @@ tcp_nodelay = true
|
||||
# [logging]
|
||||
# dir = "/tmp/greptimedb/logs"
|
||||
# level = "info"
|
||||
|
||||
# Datanode options.
|
||||
[datanode]
|
||||
# Datanode client options.
|
||||
[datanode.client]
|
||||
timeout = "10s"
|
||||
connect_timeout = "10s"
|
||||
tcp_nodelay = true
|
||||
|
||||
@@ -38,6 +38,7 @@ datatypes = { path = "../datatypes" }
|
||||
file-table-engine = { path = "../file-table-engine" }
|
||||
futures = "0.3"
|
||||
futures-util.workspace = true
|
||||
humantime-serde = "1.1"
|
||||
itertools.workspace = true
|
||||
meta-client = { path = "../meta-client" }
|
||||
meter-macros.workspace = true
|
||||
|
||||
@@ -20,8 +20,8 @@ use servers::http::HttpOptions;
|
||||
use servers::Mode;
|
||||
|
||||
use crate::service_config::{
|
||||
GrpcOptions, InfluxdbOptions, MysqlOptions, OpentsdbOptions, OtlpOptions, PostgresOptions,
|
||||
PromStoreOptions, PrometheusOptions,
|
||||
DatanodeOptions, GrpcOptions, InfluxdbOptions, MysqlOptions, OpentsdbOptions, OtlpOptions,
|
||||
PostgresOptions, PromStoreOptions, PrometheusOptions,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
@@ -41,6 +41,7 @@ pub struct FrontendOptions {
|
||||
pub otlp_options: Option<OtlpOptions>,
|
||||
pub meta_client_options: Option<MetaClientOptions>,
|
||||
pub logging: LoggingOptions,
|
||||
pub datanode: DatanodeOptions,
|
||||
}
|
||||
|
||||
impl Default for FrontendOptions {
|
||||
@@ -60,6 +61,7 @@ impl Default for FrontendOptions {
|
||||
otlp_options: Some(OtlpOptions::default()),
|
||||
meta_client_options: None,
|
||||
logging: LoggingOptions::default(),
|
||||
datanode: DatanodeOptions::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub mod datanode;
|
||||
pub mod grpc;
|
||||
pub mod influxdb;
|
||||
pub mod mysql;
|
||||
@@ -29,3 +30,5 @@ pub use otlp::OtlpOptions;
|
||||
pub use postgres::PostgresOptions;
|
||||
pub use prom_store::PromStoreOptions;
|
||||
pub use prometheus::PrometheusOptions;
|
||||
|
||||
pub use self::datanode::DatanodeOptions;
|
||||
|
||||
44
src/frontend/src/service_config/datanode.rs
Normal file
44
src/frontend/src/service_config/datanode.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2023 Greptime Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use common_grpc::channel_manager;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
pub struct DatanodeOptions {
|
||||
client: DatanodeClientOptions,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct DatanodeClientOptions {
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub timeout: Duration,
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub connect_timeout: Duration,
|
||||
pub tcp_nodelay: bool,
|
||||
}
|
||||
|
||||
impl Default for DatanodeClientOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
timeout: Duration::from_secs(channel_manager::DEFAULT_GRPC_REQUEST_TIMEOUT_SECS),
|
||||
connect_timeout: Duration::from_secs(
|
||||
channel_manager::DEFAULT_GRPC_CONNECT_TIMEOUT_SECS,
|
||||
),
|
||||
tcp_nodelay: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user