build: disable local IP detection feature in Android binary (#5327)

build: disable local ip detection feature in android binary
This commit is contained in:
Weny Xu
2025-01-09 19:13:48 +08:00
committed by GitHub
parent d33309be2b
commit be22da775a
4 changed files with 22 additions and 2 deletions

View File

@@ -11,6 +11,9 @@ pg_kvbackend = ["dep:tokio-postgres", "common-meta/pg_kvbackend"]
[lints]
workspace = true
[target.'cfg(not(target_os = "android"))'.dependencies]
local-ip-address.workspace = true
[dependencies]
api.workspace = true
async-trait = "0.1"
@@ -45,7 +48,6 @@ humantime.workspace = true
humantime-serde.workspace = true
itertools.workspace = true
lazy_static.workspace = true
local-ip-address.workspace = true
once_cell.workspace = true
parking_lot.workspace = true
prometheus.workspace = true

View File

@@ -204,6 +204,7 @@ impl Configurable for MetasrvOptions {
impl MetasrvOptions {
/// Detect server address if `auto_server_addr` is true.
#[cfg(not(target_os = "android"))]
pub fn detect_server_addr(&mut self) {
if self.server_addr.is_empty() {
match local_ip_address::local_ip() {
@@ -225,6 +226,13 @@ impl MetasrvOptions {
}
}
}
#[cfg(target_os = "android")]
pub fn detect_hostname(&mut self) {
if self.server_addr.is_empty() {
common_telemetry::debug!("detect local IP is not supported on Android");
}
}
}
pub struct MetasrvInfo {

View File

@@ -14,6 +14,9 @@ testing = []
[lints]
workspace = true
[target.'cfg(not(target_os = "android"))'.dependencies]
local-ip-address.workspace = true
[dependencies]
ahash = "0.8"
api.workspace = true
@@ -65,7 +68,6 @@ influxdb_line_protocol = { git = "https://github.com/evenyag/influxdb_iox", bran
itertools.workspace = true
jsonb.workspace = true
lazy_static.workspace = true
local-ip-address.workspace = true
log-query.workspace = true
loki-api = "0.1"
mime_guess = "2.0"

View File

@@ -67,6 +67,7 @@ pub struct GrpcOptions {
impl GrpcOptions {
/// Detect hostname if `auto_hostname` is true.
#[cfg(not(target_os = "android"))]
pub fn detect_hostname(&mut self) {
if self.hostname.is_empty() {
match local_ip_address::local_ip() {
@@ -88,6 +89,13 @@ impl GrpcOptions {
}
}
}
#[cfg(target_os = "android")]
pub fn detect_hostname(&mut self) {
if self.hostname.is_empty() {
common_telemetry::debug!("detect local IP is not supported on Android");
}
}
}
const DEFAULT_GRPC_ADDR_PORT: &str = "4001";