Repository navigation
Expand file tree
/
Copy pathCargo.toml
More file actions
78 lines (67 loc) · 3.89 KB
/
Copy pathCargo.toml
File metadata and controls
78 lines (67 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[package]
name = "brighto-router"
version = "1.1.0"
edition = "2024"
authors = ["Nguyễn Anh Nguyên <nguyen@hatto.com>"]
rust-version = "1.94" # Minimum supported Rust version required by sqlx 0.9
license = "Apache-2.0"
publish = false
[dependencies]
# --- runtime & HTTP ---
tokio = { version = "1.53.1", features = ["rt-multi-thread", "macros", "signal", "sync", "time", "net", "io-util", "fs"] }
tokio-util = { version = "0.7.19", features = ["io"] }
axum = { version = "0.8.9", default-features = false, features = ["http1", "http2", "json", "query", "tokio", "matched-path", "tracing"] }
axum-server = { version = "0.8.0", features = ["tls-rustls"] } # tls-rustls uses rustls/aws-lc-rs (matches reqwest+sqlx provider)
tower = { version = "0.5.3", features = ["util", "timeout", "limit"] }
tower-http = { version = "0.7.1", features = ["trace", "request-id", "set-header", "limit", "timeout"] }
http = "1.5.0"
http-body = "1.0.1"
bytes = "1.12.1"
futures = "0.3.34"
# --- HTTP client to backends: vLLM, llama-server, Anthropic, and compatible APIs ---
# default-features=false disables native-tls/OpenSSL. reqwest 0.13 rustls uses aws-lc-rs.
# Do not enable gzip auto-decode in the proxy. Backend requests force Accept-Encoding: identity to preserve pass-through behavior and avoid decompression CPU.
# Do not enable ring in another TLS crate at the same time; two rustls crypto providers can panic at runtime.
reqwest = { version = "0.13.5", default-features = false, features = ["rustls", "stream", "json"] }
# --- JSON: only deserialize small structs such as model, stream, and usage; do not parse full messages in the hot path ---
serde = { version = "1.0.229", features = ["derive"] }
serde_json = { version = "1.0.151", features = ["raw_value"] }
memchr = "2.8.3" # scan chunks for "usage" before parsing
# --- in-memory state ---
arc-swap = "1.9.2" # lock-free config snapshot swap
dashmap = "6.2.1" # per-instance backend inflight counters
# Keep the default fastest path PostgreSQL-only.
# --- DB: config and ledger. Production/default runtime is PostgreSQL only. ---
# tls-rustls-aws-lc-rs matches the reqwest TLS provider.
# macros + migrate support sqlx test migrations.
sqlx = { version = "0.9.0", default-features = false, features = ["runtime-tokio", "tls-rustls-aws-lc-rs", "postgres", "macros", "migrate"] }
# --- observability ---
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter", "json", "fmt"] }
metrics = "0.24.6"
metrics-exporter-prometheus = { version = "0.18.3", default-features = false } # /metrics is served through axum; no extra listener
metrics-util = { version = "0.20.4", default-features = false } # gauge idle expiry removes stale budget series after a cap is cleared
# --- utilities ---
sha2 = "0.11.0" # API-key hashing
hex = "0.4.3"
uuid = { version = "1.26.1", features = ["v7", "serde"] } # time-sortable request IDs
chrono = { version = "0.4.45", features = ["serde", "clock"] }
rand = "0.10.2"
anyhow = "1.0.104"
thiserror = "2.0.20"
clap = { version = "4.6.7", features = ["derive", "env"] }
dotenvy = "0.15.7"
[dev-dependencies]
tokio = { version = "1.53.1", features = ["test-util"] }
# Mock upstream for benchmark and failure-mode tests; fast responses make router overhead visible.
[[bin]]
name = "brighto-router-mock"
path = "src/bin/mock_upstream.rs"
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
debug = "line-tables-only" # enough for production backtraces without a large binary
strip = false
[profile.dev]
opt-level = 1 # development builds still need acceptable large-payload behavior