Skip to content

Conversation

@heilhead
Copy link
Collaborator

@heilhead heilhead commented Dec 3, 2025

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
Copy link

linear bot commented Dec 5, 2025

@chris13524
Copy link
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
Copy link
Collaborator Author

heilhead commented Dec 9, 2025

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
Copy link
Collaborator Author

heilhead commented Dec 9, 2025

@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.

4 participants