Skip to content

Commit bfd6dfc

Browse files
feat(ws): implement bidirectional WebSocket proxy (#2390)
* feat(ws): implement bidirectional WebSocket proxy - Add WebSocketProxy struct with builder pattern - Support custom headers for upstream auth via ClientRequestBuilder - Implement bidirectional message forwarding between client and upstream - Add pending message queue with control vs data message separation - Implement backpressure limit (5 MiB MAX_PENDING_QUEUE_BYTES) - Add upstream connection timeout (5s default) - Implement graceful shutdown with close code normalization - Add axum dependency with ws feature for server feature Co-Authored-By: yujonglee <[email protected]> * feat(ws): add tower::Service, preconnect API, and friendlier builder - Implement tower::Service for plug-and-play Axum routing - Add preconnect() method for latency-sensitive scenarios - Add friendlier builder API: .upstream_url(), .header(), .headers() - Add PreconnectedProxy for handling pre-established upstream connections - Add PreconnectError enum for preconnect error handling - Add handle_upgrade() method for WebSocketUpgrade handling - Add tower dependency for server feature Co-Authored-By: yujonglee <[email protected]> * chore: update Cargo.lock for tower dependency Co-Authored-By: yujonglee <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: yujonglee <[email protected]>
1 parent e16c6e7 commit bfd6dfc

File tree

3 files changed

+756
-2
lines changed

3 files changed

+756
-2
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ws/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2024"
66
[features]
77
default = ["client"]
88
client = []
9-
server = []
9+
server = ["axum", "tower"]
1010

1111
[dependencies]
1212
bytes = { workspace = true }
@@ -20,5 +20,8 @@ tokio = { workspace = true, features = ["rt-multi-thread", "time", "sync", "macr
2020
tokio-tungstenite = { workspace = true, features = ["native-tls-vendored"] }
2121
tracing = { workspace = true }
2222

23+
axum = { workspace = true, optional = true, features = ["ws"] }
24+
tower = { workspace = true, optional = true }
25+
2326
[dev-dependencies]
2427
serde_json.workspace = true

0 commit comments

Comments
 (0)