diff --git a/Cargo.lock b/Cargo.lock index 7794c11..ad15d1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1645,20 +1645,16 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" name = "signal-gateway" version = "0.1.0" dependencies = [ - "bytes", "chrono", "chrono-tz", "conf", "conf-extra", "displaydoc", - "dotenvy", "futures-util", "http", "http-body", "http-body-util", "humantime", - "hyper", - "hyper-util", "jsonrpsee", "prometheus-http-client", "rand", @@ -1669,11 +1665,26 @@ dependencies = [ "tokio", "tokio-util", "tracing", - "tracing-subscriber", "url", "walkdir", ] +[[package]] +name = "signal-gateway-bin" +version = "0.1.0" +dependencies = [ + "conf", + "dotenvy", + "hyper", + "hyper-util", + "signal-gateway", + "syslog_rfc5424", + "tokio", + "tokio-util", + "tracing", + "tracing-subscriber", +] + [[package]] name = "signal-hook-registry" version = "1.4.7" diff --git a/Cargo.toml b/Cargo.toml index 9bd6061..3c29366 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = [ "prometheus-http-client", "signal-gateway", + "signal-gateway-bin", ] [workspace.package] @@ -24,7 +25,6 @@ result_large_err = "allow" prometheus-http-client = { path = "prometheus-http-client", default-features = false } async-trait = "0.1" -bytes = "1" chrono = { version = "0.4", default-features = false, features = ["clock", "serde", "std"] } chrono-tz = "0.10" conf = "0.4" @@ -46,7 +46,7 @@ serde = { version = "1", features = ["derive"] } serde_json = "1" syslog_rfc5424 = "0.10" thiserror = "2" -tokio = { version = "1", features = ["io-util", "macros", "net", "rt-multi-thread", "signal", "sync", "time"] } +tokio = { version = "1", features = ["io-util", "macros", "net", "sync", "time"] } tokio-util = { version = "0.7", features = ["codec"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/signal-gateway-bin/Cargo.toml b/signal-gateway-bin/Cargo.toml new file mode 100644 index 0000000..67b96f6 --- /dev/null +++ b/signal-gateway-bin/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "signal-gateway-bin" +version = "0.1.0" +edition.workspace = true + +[lints] +workspace = true + +[[bin]] +name = "signal-gateway" +path = "src/main.rs" + +[features] +default = ["signal-gateway/default"] +plot = ["signal-gateway/plot"] +rustls-tls = ["signal-gateway/rustls-tls"] + +[dependencies] +signal-gateway = { path = "../signal-gateway" } + +conf = { workspace = true } +dotenvy = { workspace = true } +hyper = { workspace = true } +hyper-util = { workspace = true } +syslog_rfc5424 = { workspace = true } +tokio = { workspace = true, features = ["rt-multi-thread", "signal"] } +tokio-util = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } diff --git a/signal-gateway/src/bin/main.rs b/signal-gateway-bin/src/main.rs similarity index 100% rename from signal-gateway/src/bin/main.rs rename to signal-gateway-bin/src/main.rs diff --git a/signal-gateway/Cargo.toml b/signal-gateway/Cargo.toml index 2d6ed86..2c209ee 100644 --- a/signal-gateway/Cargo.toml +++ b/signal-gateway/Cargo.toml @@ -10,17 +10,10 @@ workspace = true default = ["plot"] plot = ["prometheus-http-client/plot", "dep:chrono-tz", "dep:rand", "dep:walkdir"] rustls-tls = ["prometheus-http-client/rustls-tls"] -bin = ["dep:dotenvy", "dep:hyper", "dep:hyper-util", "dep:tracing-subscriber"] - -[[bin]] -name = "signal-gateway" -path = "src/bin/main.rs" -required-features = ["bin"] [dependencies] prometheus-http-client = { workspace = true, default-features = false } -bytes = { workspace = true } chrono = { workspace = true } conf = { workspace = true } conf-extra = { workspace = true } @@ -40,12 +33,6 @@ tokio-util = { workspace = true } tracing = { workspace = true } url = { workspace = true } -# Optional dependencies for bin feature -dotenvy = { workspace = true, optional = true } -hyper = { workspace = true, optional = true } -hyper-util = { workspace = true, optional = true } -tracing-subscriber = { workspace = true, optional = true } - # Optional dependencies for plot feature chrono-tz = { workspace = true, optional = true } rand = { workspace = true, optional = true } diff --git a/signal-gateway/src/gateway/mod.rs b/signal-gateway/src/gateway/mod.rs index be4487e..6a3e510 100644 --- a/signal-gateway/src/gateway/mod.rs +++ b/signal-gateway/src/gateway/mod.rs @@ -3,7 +3,7 @@ use crate::{ jsonrpc::{Envelope, RpcClient, RpcClientError, SignalMessage, connect_tcp}, prometheus::{Prometheus, PrometheusConfig}, }; -use bytes::Buf; +use tokio_util::bytes::Buf; use conf::{Conf, Subcommands}; use futures_util::FutureExt; pub use http::{Method, Request, Response, StatusCode};