diff --git a/config/config.md b/config/config.md
index 42cbe6c116..807a8141ba 100644
--- a/config/config.md
+++ b/config/config.md
@@ -29,7 +29,7 @@
| `http.enable_cors` | Bool | `true` | HTTP CORS support, it's turned on by default
This allows browser to access http APIs without CORS restrictions |
| `http.cors_allowed_origins` | Array | Unset | Customize allowed origins for HTTP CORS. |
| `grpc` | -- | -- | The gRPC server options. |
-| `grpc.addr` | String | `127.0.0.1:4001` | The address to bind the gRPC server. |
+| `grpc.bind_addr` | String | `127.0.0.1:4001` | The address to bind the gRPC server. |
| `grpc.runtime_size` | Integer | `8` | The number of server worker threads. |
| `grpc.tls` | -- | -- | gRPC server TLS options, see `mysql.tls` section. |
| `grpc.tls.mode` | String | `disable` | TLS mode. |
@@ -221,8 +221,8 @@
| `http.enable_cors` | Bool | `true` | HTTP CORS support, it's turned on by default
This allows browser to access http APIs without CORS restrictions |
| `http.cors_allowed_origins` | Array | Unset | Customize allowed origins for HTTP CORS. |
| `grpc` | -- | -- | The gRPC server options. |
-| `grpc.addr` | String | `127.0.0.1:4001` | The address to bind the gRPC server. |
-| `grpc.hostname` | String | `127.0.0.1:4001` | The hostname advertised to the metasrv,
and used for connections from outside the host |
+| `grpc.bind_addr` | String | `127.0.0.1:4001` | The address to bind the gRPC server. |
+| `grpc.server_addr` | String | `127.0.0.1:4001` | The address advertised to the metasrv, and used for connections from outside the host.
If left empty or unset, the server will automatically use the IP address of the first network interface
on the host, with the same port number as the one specified in `grpc.bind_addr`. |
| `grpc.runtime_size` | Integer | `8` | The number of server worker threads. |
| `grpc.tls` | -- | -- | gRPC server TLS options, see `mysql.tls` section. |
| `grpc.tls.mode` | String | `disable` | TLS mode. |
@@ -300,7 +300,7 @@
| --- | -----| ------- | ----------- |
| `data_home` | String | `/tmp/metasrv/` | The working home directory. |
| `bind_addr` | String | `127.0.0.1:3002` | The bind address of metasrv. |
-| `server_addr` | String | `127.0.0.1:3002` | The communication server address for frontend and datanode to connect to metasrv, "127.0.0.1:3002" by default for localhost. |
+| `server_addr` | String | `127.0.0.1:3002` | The communication server address for the frontend and datanode to connect to metasrv.
If left empty or unset, the server will automatically use the IP address of the first network interface
on the host, with the same port number as the one specified in `bind_addr`. |
| `store_addrs` | Array | -- | Store server address default to etcd store.
For postgres store, the format is:
"password=password dbname=postgres user=postgres host=localhost port=5432"
For etcd store, the format is:
"127.0.0.1:2379" |
| `store_key_prefix` | String | `""` | If it's not empty, the metasrv will store all data with this key prefix. |
| `backend` | String | `etcd_store` | The datastore for meta server.
Available values:
- `etcd_store` (default value)
- `memory_store`
- `postgres_store` |
@@ -376,8 +376,6 @@
| `init_regions_in_background` | Bool | `false` | Initialize all regions in the background during the startup.
By default, it provides services after all regions have been initialized. |
| `init_regions_parallelism` | Integer | `16` | Parallelism of initializing regions. |
| `max_concurrent_queries` | Integer | `0` | The maximum current queries allowed to be executed. Zero means unlimited. |
-| `rpc_addr` | String | Unset | Deprecated, use `grpc.addr` instead. |
-| `rpc_hostname` | String | Unset | Deprecated, use `grpc.hostname` instead. |
| `rpc_runtime_size` | Integer | Unset | Deprecated, use `grpc.runtime_size` instead. |
| `rpc_max_recv_message_size` | String | Unset | Deprecated, use `grpc.rpc_max_recv_message_size` instead. |
| `rpc_max_send_message_size` | String | Unset | Deprecated, use `grpc.rpc_max_send_message_size` instead. |
@@ -387,8 +385,8 @@
| `http.timeout` | String | `30s` | HTTP request timeout. Set to 0 to disable timeout. |
| `http.body_limit` | String | `64MB` | HTTP request body limit.
The following units are supported: `B`, `KB`, `KiB`, `MB`, `MiB`, `GB`, `GiB`, `TB`, `TiB`, `PB`, `PiB`.
Set to 0 to disable limit. |
| `grpc` | -- | -- | The gRPC server options. |
-| `grpc.addr` | String | `127.0.0.1:3001` | The address to bind the gRPC server. |
-| `grpc.hostname` | String | `127.0.0.1:3001` | The hostname advertised to the metasrv,
and used for connections from outside the host |
+| `grpc.bind_addr` | String | `127.0.0.1:3001` | The address to bind the gRPC server. |
+| `grpc.server_addr` | String | `127.0.0.1:3001` | The address advertised to the metasrv, and used for connections from outside the host.
If left empty or unset, the server will automatically use the IP address of the first network interface
on the host, with the same port number as the one specified in `grpc.bind_addr`. |
| `grpc.runtime_size` | Integer | `8` | The number of server worker threads. |
| `grpc.max_recv_message_size` | String | `512MB` | The maximum receive message size for gRPC server. |
| `grpc.max_send_message_size` | String | `512MB` | The maximum send message size for gRPC server. |
@@ -549,8 +547,8 @@
| `flow` | -- | -- | flow engine options. |
| `flow.num_workers` | Integer | `0` | The number of flow worker in flownode.
Not setting(or set to 0) this value will use the number of CPU cores divided by 2. |
| `grpc` | -- | -- | The gRPC server options. |
-| `grpc.addr` | String | `127.0.0.1:6800` | The address to bind the gRPC server. |
-| `grpc.hostname` | String | `127.0.0.1` | The hostname advertised to the metasrv,
and used for connections from outside the host |
+| `grpc.bind_addr` | String | `127.0.0.1:6800` | The address to bind the gRPC server. |
+| `grpc.server_addr` | String | `127.0.0.1:6800` | The address advertised to the metasrv,
and used for connections from outside the host |
| `grpc.runtime_size` | Integer | `2` | The number of server worker threads. |
| `grpc.max_recv_message_size` | String | `512MB` | The maximum receive message size for gRPC server. |
| `grpc.max_send_message_size` | String | `512MB` | The maximum send message size for gRPC server. |
diff --git a/config/datanode.example.toml b/config/datanode.example.toml
index 8cafdb609c..a9a73f7176 100644
--- a/config/datanode.example.toml
+++ b/config/datanode.example.toml
@@ -19,14 +19,6 @@ init_regions_parallelism = 16
## The maximum current queries allowed to be executed. Zero means unlimited.
max_concurrent_queries = 0
-## Deprecated, use `grpc.addr` instead.
-## @toml2docs:none-default
-rpc_addr = "127.0.0.1:3001"
-
-## Deprecated, use `grpc.hostname` instead.
-## @toml2docs:none-default
-rpc_hostname = "127.0.0.1"
-
## Deprecated, use `grpc.runtime_size` instead.
## @toml2docs:none-default
rpc_runtime_size = 8
@@ -56,10 +48,11 @@ body_limit = "64MB"
## The gRPC server options.
[grpc]
## The address to bind the gRPC server.
-addr = "127.0.0.1:3001"
-## The hostname advertised to the metasrv,
-## and used for connections from outside the host
-hostname = "127.0.0.1:3001"
+bind_addr = "127.0.0.1:3001"
+## The address advertised to the metasrv, and used for connections from outside the host.
+## If left empty or unset, the server will automatically use the IP address of the first network interface
+## on the host, with the same port number as the one specified in `grpc.bind_addr`.
+server_addr = "127.0.0.1:3001"
## The number of server worker threads.
runtime_size = 8
## The maximum receive message size for gRPC server.
diff --git a/config/flownode.example.toml b/config/flownode.example.toml
index 877cb08928..2ee5fdcfa0 100644
--- a/config/flownode.example.toml
+++ b/config/flownode.example.toml
@@ -14,10 +14,10 @@ node_id = 14
## The gRPC server options.
[grpc]
## The address to bind the gRPC server.
-addr = "127.0.0.1:6800"
-## The hostname advertised to the metasrv,
+bind_addr = "127.0.0.1:6800"
+## The address advertised to the metasrv,
## and used for connections from outside the host
-hostname = "127.0.0.1"
+server_addr = "127.0.0.1:6800"
## The number of server worker threads.
runtime_size = 2
## The maximum receive message size for gRPC server.
diff --git a/config/frontend.example.toml b/config/frontend.example.toml
index 2ecd7a19e8..741eaec500 100644
--- a/config/frontend.example.toml
+++ b/config/frontend.example.toml
@@ -41,10 +41,11 @@ cors_allowed_origins = ["https://example.com"]
## The gRPC server options.
[grpc]
## The address to bind the gRPC server.
-addr = "127.0.0.1:4001"
-## The hostname advertised to the metasrv,
-## and used for connections from outside the host
-hostname = "127.0.0.1:4001"
+bind_addr = "127.0.0.1:4001"
+## The address advertised to the metasrv, and used for connections from outside the host.
+## If left empty or unset, the server will automatically use the IP address of the first network interface
+## on the host, with the same port number as the one specified in `grpc.bind_addr`.
+server_addr = "127.0.0.1:4001"
## The number of server worker threads.
runtime_size = 8
diff --git a/config/metasrv.example.toml b/config/metasrv.example.toml
index 2c581834a8..18b203f204 100644
--- a/config/metasrv.example.toml
+++ b/config/metasrv.example.toml
@@ -4,7 +4,9 @@ data_home = "/tmp/metasrv/"
## The bind address of metasrv.
bind_addr = "127.0.0.1:3002"
-## The communication server address for frontend and datanode to connect to metasrv, "127.0.0.1:3002" by default for localhost.
+## The communication server address for the frontend and datanode to connect to metasrv.
+## If left empty or unset, the server will automatically use the IP address of the first network interface
+## on the host, with the same port number as the one specified in `bind_addr`.
server_addr = "127.0.0.1:3002"
## Store server address default to etcd store.
diff --git a/config/standalone.example.toml b/config/standalone.example.toml
index da1afc29fc..3d6ad64a3e 100644
--- a/config/standalone.example.toml
+++ b/config/standalone.example.toml
@@ -49,7 +49,7 @@ cors_allowed_origins = ["https://example.com"]
## The gRPC server options.
[grpc]
## The address to bind the gRPC server.
-addr = "127.0.0.1:4001"
+bind_addr = "127.0.0.1:4001"
## The number of server worker threads.
runtime_size = 8
diff --git a/src/cmd/src/datanode.rs b/src/cmd/src/datanode.rs
index bb5948edfa..c26201e7c0 100644
--- a/src/cmd/src/datanode.rs
+++ b/src/cmd/src/datanode.rs
@@ -126,10 +126,14 @@ impl SubCommand {
struct StartCommand {
#[clap(long)]
node_id: Option,
- #[clap(long)]
- rpc_addr: Option,
- #[clap(long)]
- rpc_hostname: Option,
+ /// The address to bind the gRPC server.
+ #[clap(long, alias = "rpc-addr")]
+ rpc_bind_addr: Option,
+ /// The address advertised to the metasrv, and used for connections from outside the host.
+ /// If left empty or unset, the server will automatically use the IP address of the first network interface
+ /// on the host, with the same port number as the one specified in `rpc_bind_addr`.
+ #[clap(long, alias = "rpc-hostname")]
+ rpc_server_addr: Option,
#[clap(long, value_delimiter = ',', num_args = 1..)]
metasrv_addrs: Option>,
#[clap(short, long)]
@@ -181,18 +185,18 @@ impl StartCommand {
tokio_console_addr: global_options.tokio_console_addr.clone(),
};
- if let Some(addr) = &self.rpc_addr {
- opts.grpc.addr.clone_from(addr);
+ if let Some(addr) = &self.rpc_bind_addr {
+ opts.grpc.bind_addr.clone_from(addr);
} else if let Some(addr) = &opts.rpc_addr {
warn!("Use the deprecated attribute `DatanodeOptions.rpc_addr`, please use `grpc.addr` instead.");
- opts.grpc.addr.clone_from(addr);
+ opts.grpc.bind_addr.clone_from(addr);
}
- if let Some(hostname) = &self.rpc_hostname {
- opts.grpc.hostname.clone_from(hostname);
- } else if let Some(hostname) = &opts.rpc_hostname {
+ if let Some(server_addr) = &self.rpc_server_addr {
+ opts.grpc.server_addr.clone_from(server_addr);
+ } else if let Some(server_addr) = &opts.rpc_hostname {
warn!("Use the deprecated attribute `DatanodeOptions.rpc_hostname`, please use `grpc.hostname` instead.");
- opts.grpc.hostname.clone_from(hostname);
+ opts.grpc.server_addr.clone_from(server_addr);
}
if let Some(runtime_size) = opts.rpc_runtime_size {
@@ -277,7 +281,7 @@ impl StartCommand {
let plugin_opts = opts.plugins;
let mut opts = opts.component;
- opts.grpc.detect_hostname();
+ opts.grpc.detect_server_addr();
let mut plugins = Plugins::new();
plugins::setup_datanode_plugins(&mut plugins, &plugin_opts, &opts)
.await
@@ -357,8 +361,8 @@ mod tests {
rpc_addr = "127.0.0.1:4001"
rpc_hostname = "192.168.0.1"
[grpc]
- addr = "127.0.0.1:3001"
- hostname = "127.0.0.1"
+ bind_addr = "127.0.0.1:3001"
+ server_addr = "127.0.0.1"
runtime_size = 8
"#;
write!(file, "{}", toml_str).unwrap();
@@ -369,8 +373,8 @@ mod tests {
};
let options = cmd.load_options(&Default::default()).unwrap().component;
- assert_eq!("127.0.0.1:4001".to_string(), options.grpc.addr);
- assert_eq!("192.168.0.1".to_string(), options.grpc.hostname);
+ assert_eq!("127.0.0.1:4001".to_string(), options.grpc.bind_addr);
+ assert_eq!("192.168.0.1".to_string(), options.grpc.server_addr);
}
#[test]
@@ -431,7 +435,7 @@ mod tests {
let options = cmd.load_options(&Default::default()).unwrap().component;
- assert_eq!("127.0.0.1:3001".to_string(), options.grpc.addr);
+ assert_eq!("127.0.0.1:3001".to_string(), options.grpc.bind_addr);
assert_eq!(Some(42), options.node_id);
let DatanodeWalConfig::RaftEngine(raft_engine_config) = options.wal else {
@@ -645,7 +649,7 @@ mod tests {
opts.http.addr,
DatanodeOptions::default().component.http.addr
);
- assert_eq!(opts.grpc.hostname, "10.103.174.219");
+ assert_eq!(opts.grpc.server_addr, "10.103.174.219");
},
);
}
diff --git a/src/cmd/src/flownode.rs b/src/cmd/src/flownode.rs
index bc1670977c..9280202471 100644
--- a/src/cmd/src/flownode.rs
+++ b/src/cmd/src/flownode.rs
@@ -129,11 +129,13 @@ struct StartCommand {
#[clap(long)]
node_id: Option,
/// Bind address for the gRPC server.
- #[clap(long)]
- rpc_addr: Option,
- /// Hostname for the gRPC server.
- #[clap(long)]
- rpc_hostname: Option,
+ #[clap(long, alias = "rpc-addr")]
+ rpc_bind_addr: Option,
+ /// The address advertised to the metasrv, and used for connections from outside the host.
+ /// If left empty or unset, the server will automatically use the IP address of the first network interface
+ /// on the host, with the same port number as the one specified in `rpc_bind_addr`.
+ #[clap(long, alias = "rpc-hostname")]
+ rpc_server_addr: Option,
/// Metasrv address list;
#[clap(long, value_delimiter = ',', num_args = 1..)]
metasrv_addrs: Option>,
@@ -184,12 +186,12 @@ impl StartCommand {
tokio_console_addr: global_options.tokio_console_addr.clone(),
};
- if let Some(addr) = &self.rpc_addr {
- opts.grpc.addr.clone_from(addr);
+ if let Some(addr) = &self.rpc_bind_addr {
+ opts.grpc.bind_addr.clone_from(addr);
}
- if let Some(hostname) = &self.rpc_hostname {
- opts.grpc.hostname.clone_from(hostname);
+ if let Some(server_addr) = &self.rpc_server_addr {
+ opts.grpc.server_addr.clone_from(server_addr);
}
if let Some(node_id) = self.node_id {
@@ -237,7 +239,7 @@ impl StartCommand {
info!("Flownode options: {:#?}", opts);
let mut opts = opts.component;
- opts.grpc.detect_hostname();
+ opts.grpc.detect_server_addr();
// TODO(discord9): make it not optionale after cluster id is required
let cluster_id = opts.cluster_id.unwrap_or(0);
diff --git a/src/cmd/src/frontend.rs b/src/cmd/src/frontend.rs
index 264411943f..3324328a8c 100644
--- a/src/cmd/src/frontend.rs
+++ b/src/cmd/src/frontend.rs
@@ -136,13 +136,19 @@ impl SubCommand {
#[derive(Debug, Default, Parser)]
pub struct StartCommand {
+ /// The address to bind the gRPC server.
+ #[clap(long, alias = "rpc-addr")]
+ rpc_bind_addr: Option,
+ /// The address advertised to the metasrv, and used for connections from outside the host.
+ /// If left empty or unset, the server will automatically use the IP address of the first network interface
+ /// on the host, with the same port number as the one specified in `rpc_bind_addr`.
+ #[clap(long, alias = "rpc-hostname")]
+ rpc_server_addr: Option,
#[clap(long)]
http_addr: Option,
#[clap(long)]
http_timeout: Option,
#[clap(long)]
- rpc_addr: Option,
- #[clap(long)]
mysql_addr: Option,
#[clap(long)]
postgres_addr: Option,
@@ -218,11 +224,15 @@ impl StartCommand {
opts.http.disable_dashboard = disable_dashboard;
}
- if let Some(addr) = &self.rpc_addr {
- opts.grpc.addr.clone_from(addr);
+ if let Some(addr) = &self.rpc_bind_addr {
+ opts.grpc.bind_addr.clone_from(addr);
opts.grpc.tls = tls_opts.clone();
}
+ if let Some(addr) = &self.rpc_server_addr {
+ opts.grpc.server_addr.clone_from(addr);
+ }
+
if let Some(addr) = &self.mysql_addr {
opts.mysql.enable = true;
opts.mysql.addr.clone_from(addr);
@@ -269,7 +279,7 @@ impl StartCommand {
let plugin_opts = opts.plugins;
let mut opts = opts.component;
- opts.grpc.detect_hostname();
+ opts.grpc.detect_server_addr();
let mut plugins = Plugins::new();
plugins::setup_frontend_plugins(&mut plugins, &plugin_opts, &opts)
.await
@@ -413,7 +423,7 @@ mod tests {
let default_opts = FrontendOptions::default().component;
- assert_eq!(opts.grpc.addr, default_opts.grpc.addr);
+ assert_eq!(opts.grpc.bind_addr, default_opts.grpc.bind_addr);
assert!(opts.mysql.enable);
assert_eq!(opts.mysql.runtime_size, default_opts.mysql.runtime_size);
assert!(opts.postgres.enable);
@@ -604,7 +614,7 @@ mod tests {
assert_eq!(fe_opts.http.addr, "127.0.0.1:14000");
// Should be default value.
- assert_eq!(fe_opts.grpc.addr, GrpcOptions::default().addr);
+ assert_eq!(fe_opts.grpc.bind_addr, GrpcOptions::default().bind_addr);
},
);
}
diff --git a/src/cmd/src/metasrv.rs b/src/cmd/src/metasrv.rs
index 6af4e599e0..127defe031 100644
--- a/src/cmd/src/metasrv.rs
+++ b/src/cmd/src/metasrv.rs
@@ -133,11 +133,15 @@ impl SubCommand {
#[derive(Debug, Default, Parser)]
struct StartCommand {
- #[clap(long)]
- bind_addr: Option,
- #[clap(long)]
- server_addr: Option,
- #[clap(long, aliases = ["store-addr"], value_delimiter = ',', num_args = 1..)]
+ /// The address to bind the gRPC server.
+ #[clap(long, alias = "bind-addr")]
+ rpc_bind_addr: Option,
+ /// The communication server address for the frontend and datanode to connect to metasrv.
+ /// If left empty or unset, the server will automatically use the IP address of the first network interface
+ /// on the host, with the same port number as the one specified in `rpc_bind_addr`.
+ #[clap(long, alias = "server-addr")]
+ rpc_server_addr: Option,
+ #[clap(long, alias = "store-addr", value_delimiter = ',', num_args = 1..)]
store_addrs: Option>,
#[clap(short, long)]
config_file: Option,
@@ -201,11 +205,11 @@ impl StartCommand {
tokio_console_addr: global_options.tokio_console_addr.clone(),
};
- if let Some(addr) = &self.bind_addr {
+ if let Some(addr) = &self.rpc_bind_addr {
opts.bind_addr.clone_from(addr);
}
- if let Some(addr) = &self.server_addr {
+ if let Some(addr) = &self.rpc_server_addr {
opts.server_addr.clone_from(addr);
}
@@ -269,11 +273,13 @@ impl StartCommand {
log_versions(version(), short_version(), APP_NAME);
info!("Metasrv start command: {:#?}", self);
- info!("Metasrv options: {:#?}", opts);
let plugin_opts = opts.plugins;
let mut opts = opts.component;
opts.detect_server_addr();
+
+ info!("Metasrv options: {:#?}", opts);
+
let mut plugins = Plugins::new();
plugins::setup_metasrv_plugins(&mut plugins, &plugin_opts, &opts)
.await
@@ -306,8 +312,8 @@ mod tests {
#[test]
fn test_read_from_cmd() {
let cmd = StartCommand {
- bind_addr: Some("127.0.0.1:3002".to_string()),
- server_addr: Some("127.0.0.1:3002".to_string()),
+ rpc_bind_addr: Some("127.0.0.1:3002".to_string()),
+ rpc_server_addr: Some("127.0.0.1:3002".to_string()),
store_addrs: Some(vec!["127.0.0.1:2380".to_string()]),
selector: Some("LoadBased".to_string()),
..Default::default()
@@ -381,8 +387,8 @@ mod tests {
#[test]
fn test_load_log_options_from_cli() {
let cmd = StartCommand {
- bind_addr: Some("127.0.0.1:3002".to_string()),
- server_addr: Some("127.0.0.1:3002".to_string()),
+ rpc_bind_addr: Some("127.0.0.1:3002".to_string()),
+ rpc_server_addr: Some("127.0.0.1:3002".to_string()),
store_addrs: Some(vec!["127.0.0.1:2380".to_string()]),
selector: Some("LoadBased".to_string()),
..Default::default()
diff --git a/src/cmd/src/standalone.rs b/src/cmd/src/standalone.rs
index 93abfa9605..23e27d4e71 100644
--- a/src/cmd/src/standalone.rs
+++ b/src/cmd/src/standalone.rs
@@ -329,8 +329,8 @@ impl App for Instance {
pub struct StartCommand {
#[clap(long)]
http_addr: Option,
- #[clap(long)]
- rpc_addr: Option,
+ #[clap(long, alias = "rpc-addr")]
+ rpc_bind_addr: Option,
#[clap(long)]
mysql_addr: Option,
#[clap(long)]
@@ -407,9 +407,9 @@ impl StartCommand {
opts.storage.data_home.clone_from(data_home);
}
- if let Some(addr) = &self.rpc_addr {
+ if let Some(addr) = &self.rpc_bind_addr {
// frontend grpc addr conflict with datanode default grpc addr
- let datanode_grpc_addr = DatanodeOptions::default().grpc.addr;
+ let datanode_grpc_addr = DatanodeOptions::default().grpc.bind_addr;
if addr.eq(&datanode_grpc_addr) {
return IllegalConfigSnafu {
msg: format!(
@@ -417,7 +417,7 @@ impl StartCommand {
),
}.fail();
}
- opts.grpc.addr.clone_from(addr)
+ opts.grpc.bind_addr.clone_from(addr)
}
if let Some(addr) = &self.mysql_addr {
@@ -464,7 +464,7 @@ impl StartCommand {
let mut plugins = Plugins::new();
let plugin_opts = opts.plugins;
let mut opts = opts.component;
- opts.grpc.detect_hostname();
+ opts.grpc.detect_server_addr();
let fe_opts = opts.frontend_options();
let dn_opts = opts.datanode_options();
@@ -907,7 +907,7 @@ mod tests {
assert_eq!("127.0.0.1:4000".to_string(), fe_opts.http.addr);
assert_eq!(Duration::from_secs(33), fe_opts.http.timeout);
assert_eq!(ReadableSize::mb(128), fe_opts.http.body_limit);
- assert_eq!("127.0.0.1:4001".to_string(), fe_opts.grpc.addr);
+ assert_eq!("127.0.0.1:4001".to_string(), fe_opts.grpc.bind_addr);
assert!(fe_opts.mysql.enable);
assert_eq!("127.0.0.1:4002", fe_opts.mysql.addr);
assert_eq!(2, fe_opts.mysql.runtime_size);
@@ -1037,7 +1037,7 @@ mod tests {
assert_eq!(ReadableSize::mb(64), fe_opts.http.body_limit);
// Should be default value.
- assert_eq!(fe_opts.grpc.addr, GrpcOptions::default().addr);
+ assert_eq!(fe_opts.grpc.bind_addr, GrpcOptions::default().bind_addr);
},
);
}
diff --git a/src/cmd/tests/load_config_test.rs b/src/cmd/tests/load_config_test.rs
index f913964694..3380783822 100644
--- a/src/cmd/tests/load_config_test.rs
+++ b/src/cmd/tests/load_config_test.rs
@@ -91,10 +91,8 @@ fn test_load_datanode_example_config() {
..Default::default()
},
grpc: GrpcOptions::default()
- .with_addr("127.0.0.1:3001")
- .with_hostname("127.0.0.1:3001"),
- rpc_addr: Some("127.0.0.1:3001".to_string()),
- rpc_hostname: Some("127.0.0.1".to_string()),
+ .with_bind_addr("127.0.0.1:3001")
+ .with_server_addr("127.0.0.1:3001"),
rpc_runtime_size: Some(8),
rpc_max_recv_message_size: Some(DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE),
rpc_max_send_message_size: Some(DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE),
@@ -144,7 +142,9 @@ fn test_load_frontend_example_config() {
remote_write: Some(Default::default()),
..Default::default()
},
- grpc: GrpcOptions::default().with_hostname("127.0.0.1:4001"),
+ grpc: GrpcOptions::default()
+ .with_bind_addr("127.0.0.1:4001")
+ .with_server_addr("127.0.0.1:4001"),
http: HttpOptions {
cors_allowed_origins: vec!["https://example.com".to_string()],
..Default::default()
diff --git a/src/datanode/src/config.rs b/src/datanode/src/config.rs
index 2ac2ec0e44..c873e6ba7c 100644
--- a/src/datanode/src/config.rs
+++ b/src/datanode/src/config.rs
@@ -394,7 +394,7 @@ impl Default for DatanodeOptions {
require_lease_before_startup: false,
init_regions_in_background: false,
init_regions_parallelism: 16,
- grpc: GrpcOptions::default().with_addr("127.0.0.1:3001"),
+ grpc: GrpcOptions::default().with_bind_addr("127.0.0.1:3001"),
http: HttpOptions::default(),
meta_client: None,
wal: DatanodeWalConfig::default(),
diff --git a/src/datanode/src/heartbeat.rs b/src/datanode/src/heartbeat.rs
index a42edd0292..1db411ddff 100644
--- a/src/datanode/src/heartbeat.rs
+++ b/src/datanode/src/heartbeat.rs
@@ -89,7 +89,7 @@ impl HeartbeatTask {
node_id: opts.node_id.unwrap_or(0),
// We use datanode's start time millis as the node's epoch.
node_epoch: common_time::util::current_time_millis() as u64,
- peer_addr: addrs::resolve_addr(&opts.grpc.addr, Some(&opts.grpc.hostname)),
+ peer_addr: addrs::resolve_addr(&opts.grpc.bind_addr, Some(&opts.grpc.server_addr)),
running: Arc::new(AtomicBool::new(false)),
meta_client,
region_server,
diff --git a/src/datanode/src/service.rs b/src/datanode/src/service.rs
index 22605b44b9..a5c2cbac66 100644
--- a/src/datanode/src/service.rs
+++ b/src/datanode/src/service.rs
@@ -66,8 +66,8 @@ impl<'a> DatanodeServiceBuilder<'a> {
let handlers = ServerHandlers::default();
if let Some(grpc_server) = self.grpc_server.take() {
- let addr: SocketAddr = self.opts.grpc.addr.parse().context(ParseAddrSnafu {
- addr: &self.opts.grpc.addr,
+ let addr: SocketAddr = self.opts.grpc.bind_addr.parse().context(ParseAddrSnafu {
+ addr: &self.opts.grpc.bind_addr,
})?;
let handler: ServerHandler = (Box::new(grpc_server), addr);
handlers.insert(handler).await;
diff --git a/src/flow/src/adapter.rs b/src/flow/src/adapter.rs
index 777dcbcdf8..47557752f9 100644
--- a/src/flow/src/adapter.rs
+++ b/src/flow/src/adapter.rs
@@ -121,7 +121,7 @@ impl Default for FlownodeOptions {
cluster_id: None,
node_id: None,
flow: FlowConfig::default(),
- grpc: GrpcOptions::default().with_addr("127.0.0.1:3004"),
+ grpc: GrpcOptions::default().with_bind_addr("127.0.0.1:3004"),
http: HttpOptions::default(),
meta_client: None,
logging: LoggingOptions::default(),
diff --git a/src/flow/src/heartbeat.rs b/src/flow/src/heartbeat.rs
index 69159d1d2a..4368b5d8fd 100644
--- a/src/flow/src/heartbeat.rs
+++ b/src/flow/src/heartbeat.rs
@@ -83,7 +83,7 @@ impl HeartbeatTask {
) -> Self {
Self {
node_id: opts.node_id.unwrap_or(0),
- peer_addr: addrs::resolve_addr(&opts.grpc.addr, Some(&opts.grpc.hostname)),
+ peer_addr: addrs::resolve_addr(&opts.grpc.bind_addr, Some(&opts.grpc.server_addr)),
meta_client,
report_interval: heartbeat_opts.interval,
retry_interval: heartbeat_opts.retry_interval,
diff --git a/src/flow/src/server.rs b/src/flow/src/server.rs
index 7e7434a2c6..742359818a 100644
--- a/src/flow/src/server.rs
+++ b/src/flow/src/server.rs
@@ -334,7 +334,7 @@ impl FlownodeBuilder {
let heartbeat_task = self.heartbeat_task;
- let addr = self.opts.grpc.addr;
+ let addr = self.opts.grpc.bind_addr;
let instance = FlownodeInstance {
server,
addr: addr.parse().context(ParseAddrSnafu { addr })?,
diff --git a/src/frontend/src/heartbeat.rs b/src/frontend/src/heartbeat.rs
index efa5c32286..7dc623daaa 100644
--- a/src/frontend/src/heartbeat.rs
+++ b/src/frontend/src/heartbeat.rs
@@ -56,7 +56,7 @@ impl HeartbeatTask {
resp_handler_executor: HeartbeatResponseHandlerExecutorRef,
) -> Self {
HeartbeatTask {
- peer_addr: addrs::resolve_addr(&opts.grpc.addr, Some(&opts.grpc.hostname)),
+ peer_addr: addrs::resolve_addr(&opts.grpc.bind_addr, Some(&opts.grpc.server_addr)),
meta_client,
report_interval: heartbeat_opts.interval.as_millis() as u64,
retry_interval: heartbeat_opts.retry_interval.as_millis() as u64,
diff --git a/src/frontend/src/server.rs b/src/frontend/src/server.rs
index 2e772cc145..298c48c73c 100644
--- a/src/frontend/src/server.rs
+++ b/src/frontend/src/server.rs
@@ -193,7 +193,7 @@ where
{
// Always init GRPC server
- let grpc_addr = parse_addr(&opts.grpc.addr)?;
+ let grpc_addr = parse_addr(&opts.grpc.bind_addr)?;
let grpc_server = self.build_grpc_server(&opts)?;
handlers.insert((Box::new(grpc_server), grpc_addr)).await;
}
diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs
index 098f0cb85b..d46692ebf6 100644
--- a/src/meta-srv/src/metasrv.rs
+++ b/src/meta-srv/src/metasrv.rs
@@ -203,7 +203,7 @@ impl Configurable for MetasrvOptions {
}
impl MetasrvOptions {
- /// Detect server address if `auto_server_addr` is true.
+ /// Detect server address.
#[cfg(not(target_os = "android"))]
pub fn detect_server_addr(&mut self) {
if self.server_addr.is_empty() {
diff --git a/src/servers/src/addrs.rs b/src/servers/src/addrs.rs
index c43ba4c32f..07422028f9 100644
--- a/src/servers/src/addrs.rs
+++ b/src/servers/src/addrs.rs
@@ -14,19 +14,19 @@
use common_telemetry::warn;
-/// Resolves hostname:port address for meta registration.
-/// If `hostname_addr` is present, prefer to use it, `bind_addr` otherwise.
-pub fn resolve_addr(bind_addr: &str, hostname_addr: Option<&str>) -> String {
- match hostname_addr {
- Some(hostname_addr) => {
+/// Resolves server address for meta registration.
+/// If `server_addr` is present, prefer to use it, `bind_addr` otherwise.
+pub fn resolve_addr(bind_addr: &str, server_addr: Option<&str>) -> String {
+ match server_addr {
+ Some(server_addr) => {
// it has port configured
- if hostname_addr.contains(':') {
- hostname_addr.to_string()
+ if server_addr.contains(':') {
+ server_addr.to_string()
} else {
// otherwise, resolve port from bind_addr
// should be safe to unwrap here because bind_addr is already validated
let port = bind_addr.split(':').nth(1).unwrap();
- format!("{hostname_addr}:{port}")
+ format!("{server_addr}:{port}")
}
}
None => {
diff --git a/src/servers/src/grpc.rs b/src/servers/src/grpc.rs
index 3137ec07ee..bdf07502af 100644
--- a/src/servers/src/grpc.rs
+++ b/src/servers/src/grpc.rs
@@ -55,8 +55,10 @@ type TonicResult = std::result::Result;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct GrpcOptions {
- pub addr: String,
- pub hostname: String,
+ /// The address to bind the gRPC server.
+ pub bind_addr: String,
+ /// The address to advertise to clients.
+ pub server_addr: String,
/// Max gRPC receiving(decoding) message size
pub max_recv_message_size: ReadableSize,
/// Max gRPC sending(encoding) message size
@@ -67,22 +69,22 @@ pub struct GrpcOptions {
}
impl GrpcOptions {
- /// Detect hostname if `auto_hostname` is true.
+ /// Detect the server address.
#[cfg(not(target_os = "android"))]
- pub fn detect_hostname(&mut self) {
- if self.hostname.is_empty() {
+ pub fn detect_server_addr(&mut self) {
+ if self.server_addr.is_empty() {
match local_ip_address::local_ip() {
Ok(ip) => {
let detected_addr = format!(
"{}:{}",
ip,
- self.addr
+ self.bind_addr
.split(':')
.nth(1)
.unwrap_or(DEFAULT_GRPC_ADDR_PORT)
);
info!("Using detected: {} as server address", detected_addr);
- self.hostname = detected_addr;
+ self.server_addr = detected_addr;
}
Err(e) => {
error!("Failed to detect local ip address: {}", e);
@@ -92,8 +94,8 @@ impl GrpcOptions {
}
#[cfg(target_os = "android")]
- pub fn detect_hostname(&mut self) {
- if self.hostname.is_empty() {
+ pub fn detect_server_addr(&mut self) {
+ if self.server_addr.is_empty() {
common_telemetry::debug!("detect local IP is not supported on Android");
}
}
@@ -104,9 +106,9 @@ const DEFAULT_GRPC_ADDR_PORT: &str = "4001";
impl Default for GrpcOptions {
fn default() -> Self {
Self {
- addr: format!("127.0.0.1:{}", DEFAULT_GRPC_ADDR_PORT),
+ bind_addr: format!("127.0.0.1:{}", DEFAULT_GRPC_ADDR_PORT),
// If hostname is not set, the server will use the local ip address as the hostname.
- hostname: String::new(),
+ server_addr: String::new(),
max_recv_message_size: DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE,
max_send_message_size: DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE,
runtime_size: 8,
@@ -116,13 +118,13 @@ impl Default for GrpcOptions {
}
impl GrpcOptions {
- pub fn with_addr(mut self, addr: &str) -> Self {
- self.addr = addr.to_string();
+ pub fn with_bind_addr(mut self, bind_addr: &str) -> Self {
+ self.bind_addr = bind_addr.to_string();
self
}
- pub fn with_hostname(mut self, hostname: &str) -> Self {
- self.hostname = hostname.to_string();
+ pub fn with_server_addr(mut self, server_addr: &str) -> Self {
+ self.server_addr = server_addr.to_string();
self
}
}
diff --git a/tests-fuzz/conf/standalone.template.toml b/tests-fuzz/conf/standalone.template.toml
index f0ddc38d04..585b21fa43 100644
--- a/tests-fuzz/conf/standalone.template.toml
+++ b/tests-fuzz/conf/standalone.template.toml
@@ -15,7 +15,7 @@ type = 'File'
data_home = '{data_home}'
[grpc_options]
-addr = '127.0.0.1:4001'
+bind_addr = '127.0.0.1:4001'
runtime_size = 8
[procedure]
diff --git a/tests-integration/src/standalone.rs b/tests-integration/src/standalone.rs
index 2ad62df3e1..fe12406cd1 100644
--- a/tests-integration/src/standalone.rs
+++ b/tests-integration/src/standalone.rs
@@ -293,7 +293,7 @@ impl GreptimeDbStandaloneBuilder {
procedure: procedure_config,
metadata_store: kv_backend_config,
wal: self.metasrv_wal_config.clone().into(),
- grpc: GrpcOptions::default().with_hostname("127.0.0.1:4001"),
+ grpc: GrpcOptions::default().with_server_addr("127.0.0.1:4001"),
..StandaloneOptions::default()
};
diff --git a/tests-integration/src/test_util.rs b/tests-integration/src/test_util.rs
index 626e2d96ac..1e848e5964 100644
--- a/tests-integration/src/test_util.rs
+++ b/tests-integration/src/test_util.rs
@@ -350,8 +350,8 @@ pub(crate) fn create_datanode_opts(
store: default_store,
},
grpc: GrpcOptions::default()
- .with_addr(PEER_PLACEHOLDER_ADDR)
- .with_hostname(PEER_PLACEHOLDER_ADDR),
+ .with_bind_addr(PEER_PLACEHOLDER_ADDR)
+ .with_server_addr(PEER_PLACEHOLDER_ADDR),
mode,
wal: wal_config,
..Default::default()
diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs
index e4a75aa341..6a20a46934 100644
--- a/tests-integration/tests/http.rs
+++ b/tests-integration/tests/http.rs
@@ -906,8 +906,8 @@ cors_allowed_origins = []
enable_cors = true
[grpc]
-addr = "127.0.0.1:4001"
-hostname = "127.0.0.1:4001"
+bind_addr = "127.0.0.1:4001"
+server_addr = "127.0.0.1:4001"
max_recv_message_size = "512MiB"
max_send_message_size = "512MiB"
runtime_size = 8
diff --git a/tests/conf/frontend-test.toml.template b/tests/conf/frontend-test.toml.template
index 983754e589..2f8c4f58b8 100644
--- a/tests/conf/frontend-test.toml.template
+++ b/tests/conf/frontend-test.toml.template
@@ -1,3 +1,3 @@
[grpc]
-addr = "127.0.0.1:29401"
-hostname = "127.0.0.1:29401"
\ No newline at end of file
+bind_addr = "127.0.0.1:29401"
+server_addr = "127.0.0.1:29401"
\ No newline at end of file
diff --git a/tests/conf/standalone-test.toml.template b/tests/conf/standalone-test.toml.template
index da51f3b3f4..262e106bbd 100644
--- a/tests/conf/standalone-test.toml.template
+++ b/tests/conf/standalone-test.toml.template
@@ -21,7 +21,7 @@ type = 'File'
data_home = '{data_home}'
[grpc]
-addr = '127.0.0.1:29401'
+bind_addr = '127.0.0.1:29401'
runtime_size = 8
[mysql]