Skip to content

Commit

Permalink
chore: move the sink http behind a feature sink_http
Browse files Browse the repository at this point in the history
  • Loading branch information
davidB committed Oct 5, 2024
1 parent f6351ef commit 8573af7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cdviz-collector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ opendal = { version = "0.50", default-features = false, features = [
"services-fs",
"services-s3",
], optional = true }
reqwest = { version = "0.12", default-features = false }
reqwest-middleware = { version = "0.3", features = ["json"] }
reqwest-tracing = "0.5"
reqwest = { version = "0.12", default-features = false, optional = true }
reqwest-middleware = { version = "0.3", features = ["json"], optional = true }
reqwest-tracing = { version = "0.5", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_with = "3.10"
Expand Down Expand Up @@ -77,15 +77,21 @@ tracing-subscriber = "0.3"
[features]
default = [
"sink_db",
"sink_http",
"source_http",
"source_opendal",
#reqwest is also used as transitive dependencies
"reqwest/charset",
"reqwest/http2",
"reqwest/json",
"reqwest/rustls-tls",
]
sink_db = ["dep:sqlx"]
sink_http = [
"dep:reqwest",
"dep:reqwest-middleware",
"dep:reqwest-tracing",
#reqwest is also used as transitive dependencies
"reqwest/charset",
"reqwest/http2",
"reqwest/json",
"reqwest/rustls-tls",
]
source_http = ["dep:axum", "dep:axum-tracing-opentelemetry"]
source_opendal = [
"dep:bytes",
Expand Down
5 changes: 5 additions & 0 deletions cdviz-collector/src/sinks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use tokio::task::JoinHandle;
#[cfg(feature = "sink_db")]
use db::DbSink;
use debug::DebugSink;
#[cfg(feature = "sink_http")]
use http::HttpSink;

#[derive(Clone, Debug, Deserialize, Serialize)]
Expand All @@ -22,6 +23,7 @@ pub(crate) enum Config {
Db(db::Config),
#[serde(alias = "debug")]
Debug(debug::Config),
#[cfg(feature = "sink_http")]
#[serde(alias = "http")]
Http(http::Config),
}
Expand All @@ -37,6 +39,7 @@ impl Config {
match self {
Self::Db(db::Config { enabled, .. }) => *enabled,
Self::Debug(debug::Config { enabled, .. }) => *enabled,
#[cfg(feature = "sink_http")]
Self::Http(http::Config { enabled, .. }) => *enabled,
}
}
Expand All @@ -50,6 +53,7 @@ impl TryFrom<Config> for SinkEnum {
#[cfg(feature = "sink_db")]
Config::Db(config) => DbSink::try_from(config)?.into(),
Config::Debug(config) => DebugSink::try_from(config)?.into(),
#[cfg(feature = "sink_http")]
Config::Http(config) => HttpSink::try_from(config)?.into(),
};
Ok(out)
Expand All @@ -62,6 +66,7 @@ enum SinkEnum {
#[cfg(feature = "sink_db")]
DbSink,
DebugSink,
#[cfg(feature = "sink_http")]
HttpSink,
}

Expand Down

0 comments on commit 8573af7

Please sign in to comment.