diff --git a/docs/example-cluster-0.toml b/docs/example-cluster-0.toml index 6f77ac8623..380328ddb9 100644 --- a/docs/example-cluster-0.toml +++ b/docs/example-cluster-0.toml @@ -1,4 +1,4 @@ -[service] +[server] bind_addr = "0.0.0.0" http_port = 5440 grpc_port = 8831 diff --git a/docs/example-cluster-1.toml b/docs/example-cluster-1.toml index edb858e83c..fbe20b7806 100644 --- a/docs/example-cluster-1.toml +++ b/docs/example-cluster-1.toml @@ -1,4 +1,4 @@ -[service] +[server] bind_addr = "0.0.0.0" http_port = 5441 grpc_port = 8832 diff --git a/docs/example-standalone-static-routing.toml b/docs/example-standalone-static-routing.toml index 164838febb..909586bf41 100644 --- a/docs/example-standalone-static-routing.toml +++ b/docs/example-standalone-static-routing.toml @@ -1,4 +1,4 @@ -[service] +[server] bind_addr = "0.0.0.0" http_port = 5000 grpc_port = 8831 diff --git a/docs/minimal.toml b/docs/minimal.toml index 918ee1f100..5532a48889 100644 --- a/docs/minimal.toml +++ b/docs/minimal.toml @@ -1,4 +1,4 @@ -[service] +[server] bind_addr = "0.0.0.0" http_port = 5440 grpc_port = 8831 diff --git a/integration_tests/cases/local/config.toml b/integration_tests/cases/local/config.toml index 0c5ee52f14..915118d8b9 100644 --- a/integration_tests/cases/local/config.toml +++ b/integration_tests/cases/local/config.toml @@ -1,9 +1,8 @@ -[service] +[server] bind_addr = "127.0.0.1" http_port = 5440 grpc_port = 8831 log_level = "debug" -enable_cluster = true [query] read_parallelism = 8 diff --git a/server/src/config.rs b/server/src/config.rs index 9a789e1b95..b478b04aea 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -121,7 +121,7 @@ impl From<&StaticTopologyConfig> for ClusterView { #[derive(Clone, Debug, Deserialize)] #[serde(default)] -pub struct ServiceConfig { +pub struct ServerConfig { /// The address to listen. pub bind_addr: String, pub mysql_port: u16, @@ -132,13 +132,14 @@ pub struct ServiceConfig { pub timeout: Option, /// The minimum length of the response body to compress. pub resp_compress_min_length: ReadableSize, + pub deploy_mode: DeployMode, } #[derive(Clone, Debug, Deserialize)] #[serde(default)] pub struct Config { - /// Config for service, including http, mysql and grpc. - pub service: ServiceConfig, + /// Config for service of server, including http, mysql and grpc. + pub server: ServerConfig, pub runtime: RuntimeConfig, /// Log related configs: @@ -161,7 +162,6 @@ pub struct Config { pub query: query_engine::Config, /// Deployment configs: - pub deploy_mode: DeployMode, pub cluster: ClusterConfig, /// Config of limiter @@ -182,7 +182,7 @@ impl Default for RuntimeConfig { } } -impl Default for ServiceConfig { +impl Default for ServerConfig { fn default() -> Self { Self { bind_addr: String::from("127.0.0.1"), @@ -193,6 +193,7 @@ impl Default for ServiceConfig { grpc_server_cq_count: 20, timeout: None, resp_compress_min_length: ReadableSize::mb(4), + deploy_mode: DeployMode::Standalone, } } } @@ -200,7 +201,7 @@ impl Default for ServiceConfig { impl Default for Config { fn default() -> Self { Self { - service: ServiceConfig::default(), + server: ServerConfig::default(), runtime: RuntimeConfig::default(), log_level: "debug".to_string(), enable_async_log: true, @@ -211,7 +212,6 @@ impl Default for Config { static_route: StaticRouteConfig::default(), query: query_engine::Config::default(), analytic: analytic_engine::Config::default(), - deploy_mode: DeployMode::Standalone, cluster: ClusterConfig::default(), limiter: LimiterConfig::default(), forward: forward::Config::default(), diff --git a/server/src/server.rs b/server/src/server.rs index fd3b1f8689..29550fcb52 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -283,14 +283,14 @@ impl Builder { // Create http config let endpoint = Endpoint { - addr: self.config.service.bind_addr.clone(), - port: self.config.service.http_port, + addr: self.config.server.bind_addr.clone(), + port: self.config.server.http_port, }; let http_config = HttpConfig { endpoint, - max_body_size: self.config.service.http_max_body_size, - timeout: self.config.service.timeout.map(|v| v.0), + max_body_size: self.config.server.http_max_body_size, + timeout: self.config.server.timeout.map(|v| v.0), }; // Start http service @@ -308,9 +308,9 @@ impl Builder { .context(StartHttpService)?; let mysql_config = mysql::MysqlConfig { - ip: self.config.service.bind_addr.clone(), - port: self.config.service.mysql_port, - timeout: self.config.service.timeout.map(|v| v.0), + ip: self.config.server.bind_addr.clone(), + port: self.config.server.mysql_port, + timeout: self.config.server.timeout.map(|v| v.0), }; let mysql_service = mysql::Builder::new(mysql_config) @@ -322,15 +322,15 @@ impl Builder { let router = self.router.context(MissingRouter)?; let rpc_services = grpc::Builder::new() .endpoint( - Endpoint::new(self.config.service.bind_addr, self.config.service.grpc_port) + Endpoint::new(self.config.server.bind_addr, self.config.server.grpc_port) .to_string(), ) .local_endpoint( - Endpoint::new(self.config.cluster.node.addr, self.config.service.grpc_port) + Endpoint::new(self.config.cluster.node.addr, self.config.server.grpc_port) .to_string(), ) .resp_compress_min_length( - self.config.service.resp_compress_min_length.as_bytes() as usize + self.config.server.resp_compress_min_length.as_bytes() as usize ) .runtimes(engine_runtimes) .instance(instance.clone()) @@ -338,7 +338,7 @@ impl Builder { .cluster(self.cluster.clone()) .schema_config_provider(provider) .forward_config(self.config.forward) - .timeout(self.config.service.timeout.map(|v| v.0)) + .timeout(self.config.server.timeout.map(|v| v.0)) .build() .context(BuildGrpcService)?; diff --git a/src/setup.rs b/src/setup.rs index d4274f7ae7..5eba947fe3 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -142,7 +142,7 @@ async fn run_server_with_runtimes( .limiter(limiter); let engine_builder = T::default(); - let builder = match config.deploy_mode { + let builder = match config.server.deploy_mode { DeployMode::Standalone => { build_in_standalone_mode(&config, builder, runtimes.clone(), engine_builder).await }