Skip to content

feat: websocket crate - #28

Merged
heilhead merged 4 commits into
mainfrom
feat/websocket
Dec 9, 2025
Merged

heilhead merged 4 commits into
mainfrom
feat/websocket

Conversation

@heilhead

@heilhead heilhead commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor

Description

Resolves WCN2-110.

Adds wc_websocket crate with serialization, heartbeat (keep-alive) support, idle timeout (detect disconnects), and observer support for integrating with metrics etc. Includes adapters for warp, axum and tungstenite.

The Observer and DataCodec interfaces are designed around the primary use case (server side of the Relay) to be able to integrate various inbound, outbound and latency metrics.

How Has This Been Tested?

Tests covering serialization, transport disconnect, message codecs, heartbeats and timeouts.

Due Diligence

  • Breaking change
  • Requires a documentation update
  • Requires a e2e/integration test update

@heilhead
heilhead force-pushed the feat/websocket branch 2 times, most recently from fb816d2 to 96ae206 Compare December 4, 2025 06:38
@heilhead
heilhead marked this pull request as ready for review December 5, 2025 10:16
@linear

linear Bot commented Dec 5, 2025

Copy link
Copy Markdown

Comment thread crates/websocket/src/lib.rs Outdated
Comment thread crates/websocket/src/lib.rs Outdated
@chris13524

Copy link
Copy Markdown
Member

I don't understand why relay needs an abstraction layer for this. Doesn't the relay just use 1 library at a time?

@heilhead

heilhead commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

I don't understand why relay needs an abstraction layer for this. Doesn't the relay just use 1 library at a time?

The point of having this abstraction is not multiple backends supoprt. It's to extract the common logic of serialization, observers, heartbeats and idle timeout. All of these are hard to test and ensure correctness with the current relay websocket handling code.

Lately, every minor feature that touches the transport layer in the relay (e.g. binary encoding support, request in query, batch requests etc) is impossible to integrate in a clean and testable way. It's time to refactor the transport layer, and while doing it, extract common logic like heartbeats and properly cover it with tests.

@heilhead

heilhead commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

@xDarksome I've updated the PR with what we've discussed.

Additionally:

  • Renamed the crate wc_websocket -> websocket, as the only crate using the wc_* prefix is wc_metrics.
  • Removed Cargo.lock, as we don't need it in the library code.

@heilhead
heilhead merged commit c716844 into main Dec 9, 2025
9 checks passed
@heilhead
heilhead deleted the feat/websocket branch December 9, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants