frontend/service_config/
mysql.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use serde::{Deserialize, Serialize};
16use servers::tls::TlsOption;
17
18#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
19pub struct MysqlOptions {
20    pub enable: bool,
21    pub addr: String,
22    pub runtime_size: usize,
23    #[serde(default = "Default::default")]
24    pub tls: TlsOption,
25    pub reject_no_database: Option<bool>,
26    /// Server-side keep-alive time.
27    ///
28    /// Set to 0 (default) to disable.
29    #[serde(default = "Default::default")]
30    #[serde(with = "humantime_serde")]
31    pub keep_alive: std::time::Duration,
32    pub prepared_stmt_cache_size: usize,
33}
34
35impl Default for MysqlOptions {
36    fn default() -> Self {
37        Self {
38            enable: true,
39            addr: "127.0.0.1:4002".to_string(),
40            runtime_size: 2,
41            tls: TlsOption::default(),
42            reject_no_database: None,
43            keep_alive: std::time::Duration::from_secs(0),
44            prepared_stmt_cache_size: 10000,
45        }
46    }
47}