Skip to content

Commit

Permalink
feat: auto forward query for grpc (#511)
Browse files Browse the repository at this point in the history
* add basic forwarder

* support tenent settings when forward

* avoid build forwarder when disabled

* set the local addr as config.cluster.node.addr

* make clippy happy

* add the new unit tests

* address CR issues

* fix unit test for loopback ip checking

* add some debug logs

* update the comment
  • Loading branch information
ShiKaiWi authored Dec 27, 2022
1 parent eb6af7a commit cd3f976
Show file tree
Hide file tree
Showing 6 changed files with 682 additions and 24 deletions.
32 changes: 23 additions & 9 deletions server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use serde_derive::Deserialize;
use table_engine::ANALYTIC_ENGINE_TYPE;

use crate::{
grpc::forward,
http::DEFAULT_MAX_BODY_SIZE,
limiter::LimiterConfig,
route::rule_based::{ClusterView, RuleList},
Expand Down Expand Up @@ -51,7 +52,7 @@ pub struct StaticRouteConfig {
pub topology: StaticTopologyConfig,
}

#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq)]
pub struct Endpoint {
pub addr: String,
pub port: u16,
Expand Down Expand Up @@ -101,6 +102,15 @@ impl From<Endpoint> for storage::Endpoint {
}
}

impl From<storage::Endpoint> for Endpoint {
fn from(endpoint: storage::Endpoint) -> Self {
Endpoint {
addr: endpoint.ip,
port: endpoint.port as u16,
}
}
}

#[derive(Debug, Clone, Deserialize)]
pub struct ShardView {
pub shard_id: ShardId,
Expand Down Expand Up @@ -181,34 +191,37 @@ pub struct Config {
pub grpc_port: u16,
pub grpc_server_cq_count: usize,

// Engine related configs:
/// Engine related configs:
pub runtime: RuntimeConfig,

// Log related configs:
/// Log related configs:
pub log_level: String,
pub enable_async_log: bool,
pub async_log_channel_len: i32,

// Tracing related configs:
/// Tracing related configs:
pub tracing_log_dir: String,
pub tracing_log_name: String,
pub tracing_level: String,

// Config of static router.
/// Config of static router.
pub static_route: StaticRouteConfig,

// Analytic engine configs.
/// Analytic engine configs.
pub analytic: analytic_engine::Config,

// Query engine config.
/// Query engine config.
pub query: query_engine::Config,

// Deployment configs:
/// Deployment configs:
pub deploy_mode: DeployMode,
pub cluster: ClusterConfig,

// Config of limiter
/// Config of limiter
pub limiter: LimiterConfig,

/// Config for forwarding
pub forward: forward::Config,
}

impl Default for RuntimeConfig {
Expand Down Expand Up @@ -245,6 +258,7 @@ impl Default for Config {
deploy_mode: DeployMode::Standalone,
cluster: ClusterConfig::default(),
limiter: LimiterConfig::default(),
forward: forward::Config::default(),
}
}
}
Expand Down
Loading

0 comments on commit cd3f976

Please sign in to comment.