[package]
name = "cdviz-collector"
version = "0.43.2"
edition = "2024"
description = "A service and CLI tool for collecting SDLC/CI/CD events and dispatching them as CDEvents"
homepage = "https://cdviz.dev"
repository = "https://github.com/cdviz-dev/cdviz-collector"
license = "Apache-2.0"
keywords = ["cd", "cdevents", "sdlc"]
categories = []
publish = true

[package.metadata.cargo-machete]
ignored = ["humantime-serde"]

[workspace]
members = ["testkit"]

[[bin]]
doc = false
name = "cdviz-collector"
path = "src/main.rs"

[dependencies]
async-nats = { version = "0.49", optional = true }
axum = "0.8"
axum-tracing-opentelemetry = "0.38"
base64 = "0.22"
bytes = { version = "1", optional = true }
cdevents-sdk = { version = "0.4", features = ["cloudevents"] }
cid = "0.11"
clap = { version = "4", features = ["derive", "env"] }
clap-verbosity-flag = "3"
clickhouse = { version = "0.15", default-features = false, features = [
  "lz4",
  "rustls-tls",
], optional = true }
cliclack = { version = "0.5", optional = true }
cloudevents-sdk = { version = "0.9", features = ["http-binding"] }
console = { version = "0.16", optional = true }  # compatible version with cliclack
csv = { version = "1", optional = true }
derive_more = { version = "2", features = [
  "debug",
  "display",
  "error",
  "from",
] }
async-trait = { version = "0.1", optional = true }
enum_dispatch = "0.3"
http = { version = "1", optional = true }
eventsource-stream = { version = "0.2", optional = true }
faster-hex = "0.10"
figment = { version = "0.10", features = ["env"] }
figment_file_provider_adapter = "0.1"
futures = "0.3"
futures-core = { version = "0.3", optional = true }
futures-timer = { version = "3", optional = true }
globset = "0.4"
hmac = "0.13"
indexmap = "2"
humantime-serde = "1"
init-tracing-opentelemetry = { version = "0.38", features = [
  "logfmt",
  "otlp",
  "tracing_subscriber_ext",
] }
jiff = { version = "0.2", features = ["serde"] }
miette = { version = "7", features = ["fancy"] }
mime = { version = "0.3", optional = true }
multihash = "0.19"
nom = { version = "8", optional = true }
opendal = { version = "0.57", default-features = false, features = [
  "auto-register-services",
  "services-fs",
  # "services-ftp",
  "services-gcs",
  "services-github",
  "services-http",
  "services-s3",
  "services-sftp",
], optional = true }
packageurl = "0.6"
pin-project-lite = { version = "0.2", optional = true }
quick-xml-to-json = "0.2"
rdkafka = { version = "0.39", default-features = false, features = [
  "cmake-build",
  "curl-static",
  "libz-static",
  "ssl-vendored",
  "static-linking",
  "tokio",
], optional = true }
regex = "1"
httpdate = { version = "1", optional = true }
reqwest = { version = "0.13", default-features = false, optional = true }
reqwest-middleware = { version = "0.5", features = ["json"], optional = true }
reqwest-retry = { version = "0.9", optional = true }
reqwest-tracing = { version = "0.7", optional = true }
retry-policies = { version = "0.5", optional = true }
secrecy = { version = "0.10", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_with = "3"
serde_yaml = { version = "0.9", optional = true }
sha2 = "0.11"
similar = { version = "3", features = ["inline", "unicode"], optional = true }
sqlx = { version = "0.9", default-features = false, features = [
  "json",
  "macros",
  "postgres",
  "runtime-tokio",
  "time",
  "tls-rustls",
], optional = true }
tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0.1", features = ["sync"], optional = true }
tokio-util = "0.7"
toml = "1.0"
tower = { version = "0.5", features = ["util"] }
tower-http = { version = "0.7", features = [
  "compression-full",
  "cors",
  "decompression-full",
  "sensitive-headers",
  "timeout",
  "validate-request",
] }
tracing = "0.1"
tracing-opentelemetry-instrumentation-sdk = { version = "0.38" }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
url = "2.5.7"
uuid = { version = "1", optional = true }
vrl = { version = "0.33", default-features = false, features = [
  "compiler",
  "core",
  "diagnostic",
  "parser",
  "path",
  "stdlib",
  "value",
], optional = true }

[dev-dependencies]
assert2 = "0.4"
cdevents-sdk = { version = "0.4", features = ["testkit"] }
cdviz-collector-testkit = { path = "testkit" }
figment = { version = "0.10", features = ["env", "test"] }
indoc = "2"
insta = { version = "1", features = ["yaml"] }
pretty_assertions = "1"
proptest = "1"
rstest = "0.26"
tempfile = "3"
test-strategy = "0.4"
test-trace = "0.3"
testcontainers = "0.27"  # version linked to testcontainers-*
# testcontainers-redpanda-rs = "0.12" # vendored into testkit
# time = "=0.3.39" # HACK explicit fix version (not used) to avoid compilation errors on domain #see https://github.com/NLnetLabs/domain/issues/502
tower = { version = "0.5", features = ["util"] }
wiremock = "0.6"

[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
version = "0.5"

[features]
## default is "full" feature set minus kafka (require native tools)
default = [
  "config_http",
  "config_remote",
  "parser_all",
  "sink_default",
  "source_default",
  "tool_transform",
  "transformer_vrl",
]
#! ### Configuration
config_http = ["http_client"]
config_remote = ["dep:opendal"]
#! ### Misc
http_client = [
  "dep:async-trait",
  "dep:http",
  "dep:httpdate",
  "dep:reqwest",
  "dep:reqwest-middleware",
  "dep:reqwest-retry",
  "dep:reqwest-tracing",
  # reqwest is also used as transitive dependencies
  "reqwest/charset",
  "reqwest/http2",
  "reqwest/json",
  "reqwest/rustls",
]
#! ### Parsers
parser_all = ["parser_csv_row", "parser_tap", "parser_xml", "parser_yaml"]
parser_csv_row = ["dep:csv"]
parser_tap = ["dep:nom", "parser_yaml"]
parser_xml = []
parser_yaml = ["dep:serde_yaml"]
#! ### Internal fork/vendoring
#! replace `reqwest-eventsource = { version = "0.6", optional = true }`
reqwest-eventsource = [
  "dep:eventsource-stream",
  "dep:futures-core",
  "dep:futures-timer",
  "dep:mime",
  "dep:nom",
  "dep:pin-project-lite",
  "reqwest/stream",
]
#! ### Sinks
sink_all = [
  "sink_clickhouse",
  "sink_db",
  "sink_folder",
  "sink_http",
  "sink_kafka",
  "sink_nats",
  "sink_sse",
]
sink_default = [
  "sink_clickhouse",
  "sink_db",
  "sink_folder",
  "sink_http",
  # "sink_kafka",
  "sink_nats",
  "sink_sse",
]
sink_clickhouse = ["dep:clickhouse", "dep:retry-policies"]
sink_db = ["dep:retry-policies", "dep:sqlx"]
sink_folder = ["dep:opendal"]
sink_http = ["http_client"]
sink_kafka = ["dep:rdkafka"]
sink_nats = ["dep:async-nats"]
sink_sse = ["dep:tokio-stream"]
#! ### Sources
source_all = [
  "source_http_polling",
  "source_kafka",
  "source_nats",
  "source_opendal",
  "source_sse",
]
source_default = [
  "source_http_polling",
  # "source_kafka",
  "source_nats",
  "source_opendal",
  "source_sse",
]
source_http_polling = ["http_client", "transformer_vrl"]
source_kafka = ["dep:rdkafka"]
source_nats = ["dep:async-nats"]
source_opendal = ["dep:bytes", "dep:opendal", "state"]
source_sse = ["dep:uuid", "reqwest-eventsource"]
#! ### Persist state (for sources,...)
state = ["dep:opendal"]
#! ### Tools
tool_transform = ["source_opendal", "tool_ui", "transformer_vrl"]
tool_ui = ["dep:cliclack", "dep:console", "dep:similar"]
#! ### Transformers
transformer_vrl = ["dep:vrl"]

[lints.clippy]
cargo = { level = "allow", priority = -1 }  # not published as crate
dbg_macro = "warn"
decimal_literal_representation = "warn"
expect_used = "warn"
if_then_some_else_none = "warn"
indexing_slicing = "allow"
large_include_file = "warn"
module_name_repetitions = "allow"
pedantic = { level = "warn", priority = -1 }
perf = { level = "warn", priority = -1 }
# min_ident_chars = "warn"
print_stderr = "warn"
print_stdout = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
undocumented_unsafe_blocks = "deny"
unnecessary_safety_doc = "warn"
unwrap_used = "warn"

[lints.rust]
deprecated = "warn"
missing_docs = "allow"  # not published as crate
unsafe_code = "forbid"
warnings = "deny"

[profile.release]
strip = "symbols"  # "none", "debuginfo", "symbols"
lto = "thin"  # see https://doc.rust-lang.org/cargo/reference/profiles.html#lto
codegen-units = 1

# The profile that 'dist' will build with
[profile.dist]
inherits = "release"
