ceresdb_client/config.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
//! Options in client
use std::time::Duration;
/// Config for the underlying grpc client
#[derive(Debug, Clone)]
pub struct RpcConfig {
/// Thread num used by the grpc client.
///
/// The number of cpu cores will be used if not set.
pub thread_num: Option<usize>,
/// The max length of the message sent to server.
///
/// -1 means unlimited, and the default value is 20MB.
pub max_send_msg_len: i32,
/// The max length of the message received from server.
///
/// -1 means unlimited, and the default value is 1GB.
pub max_recv_msg_len: i32,
/// The interval for htt2 ping frames.
///
/// Default value is 600s.
pub keep_alive_interval: Duration,
/// Timeout for http2 ping frame acknowledgement.
///
/// If the ping is not acknowledged within the timeout, the connection will
/// be closed, and default value is 3s.
pub keep_alive_timeout: Duration,
/// Enables http2_keep_alive or not.
///
/// It is enabled by default.
pub keep_alive_while_idle: bool,
/// Timeout for write operation.
///
/// Default value is 5s.
pub default_write_timeout: Duration,
/// Timeout for sql_query operation.
///
/// Default value is 60s.
pub default_sql_query_timeout: Duration,
/// Timeout for connection.
///
/// Default value is 3s.
pub connect_timeout: Duration,
}
impl Default for RpcConfig {
fn default() -> Self {
Self {
thread_num: None,
// 20MB
max_send_msg_len: 20 * (1 << 20),
// 1GB
max_recv_msg_len: 1 << 30,
keep_alive_interval: Duration::from_secs(60 * 10),
keep_alive_timeout: Duration::from_secs(3),
keep_alive_while_idle: true,
default_write_timeout: Duration::from_secs(5),
default_sql_query_timeout: Duration::from_secs(60),
connect_timeout: Duration::from_secs(3),
}
}
}