From 7c2bb3e424a8d84c85a31b1ed315dd4fc55b1242 Mon Sep 17 00:00:00 2001 From: AdheipSingh <34169002+AdheipSingh@users.noreply.github.com> Date: Fri, 10 Jan 2025 19:42:41 +0530 Subject: [PATCH] fixes for kafka on macOS (#1090) --- Cargo.toml | 6 +++--- src/cli.rs | 15 ++++++++++++--- src/lib.rs | 5 ++++- src/main.rs | 10 ++++++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 19d22875..6f06904e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,9 +99,6 @@ sysinfo = "0.31.4" thread-priority = "1.0.0" uptime_lib = "0.3.0" -# Kafka -rdkafka = { version = "0.36.2", default-features = false, features = ["tokio"] } - # Utility Libraries anyhow = { version = "1.0", features = ["backtrace"] } bytes = "1.4" @@ -156,3 +153,6 @@ codegen-units = 1 # adding rdkafka here because, for unsupported platforms, cargo skips other deps which come after this [target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies] rdkafka = { version = "0.36.2", default-features = false, features = ["tokio"] } + +[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies] +rdkafka = { version = "0.36.2", default-features = false, features = ["tokio"] } \ No newline at end of file diff --git a/src/cli.rs b/src/cli.rs index 42333951..c1061cd6 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -26,10 +26,16 @@ use crate::{ option::{validation, Compression, Mode}, }; -#[cfg(all(target_os = "linux", target_arch = "x86_64"))] +#[cfg(any( + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "macos", target_arch = "aarch64") +))] use crate::kafka::SslProtocol as KafkaSslProtocol; -#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))] +#[cfg(not(any( + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "macos", target_arch = "aarch64") +)))] use std::string::String as KafkaSslProtocol; #[derive(Debug, Default)] @@ -507,7 +513,10 @@ impl FromArgMatches for Cli { } fn update_from_arg_matches(&mut self, m: &clap::ArgMatches) -> Result<(), clap::Error> { - #[cfg(all(target_os = "linux", target_arch = "x86_64"))] + #[cfg(any( + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "macos", target_arch = "aarch64") + ))] { self.kafka_topics = m.get_one::(Self::KAFKA_TOPICS).cloned(); self.kafka_security_protocol = m diff --git a/src/lib.rs b/src/lib.rs index c2ab80bf..973406cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,7 +27,10 @@ pub mod correlation; mod event; pub mod handlers; pub mod hottier; -#[cfg(all(target_os = "linux", target_arch = "x86_64"))] +#[cfg(any( + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "macos", target_arch = "aarch64") +))] pub mod kafka; mod livetail; mod metadata; diff --git a/src/main.rs b/src/main.rs index 79837233..80607a6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,10 @@ use parseable::{ }; use tracing_subscriber::EnvFilter; -#[cfg(all(target_os = "linux", target_arch = "x86_64"))] +#[cfg(any( + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "macos", target_arch = "aarch64") +))] use parseable::kafka; #[actix_web::main] @@ -49,7 +52,10 @@ async fn main() -> anyhow::Result<()> { // keep metadata info in mem metadata.set_global(); - #[cfg(all(target_os = "linux", target_arch = "x86_64"))] + #[cfg(any( + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "macos", target_arch = "aarch64") + ))] // load kafka server if CONFIG.parseable.mode != Mode::Query { tokio::task::spawn(kafka::setup_integration());