Skip to content

Commit 614c99a

Browse files
authored
Refactor networking from signalling into a new livekit-net crate (#1258)
Supersedes #1229. Fixes CLT-2177 This PR is the first of three: - [ ] refactor. This moves networking from signalling into a new livekit-net crate. - [ ] expand. This adds support for the livekit-net transport to be injected by the host platform - [ ] migrate - [ ] contract. This removes support for the default native transport provided by reqwest and tungstenite. `livekit-net` introduces a `PlatformTransport` trait, which client crates then use to call out to the network. Start in the `livekit-net/src/transport.rs` file. This covers the websocket interface and http, so feasibly we might have also call this network client. The large line difference: - about +762-804 is just for `Cargo.lock` - almost all of the new livekit-net crate is just cut/paste/adapt from livekit-api: +946 -0 for the livekit-net, then +214 −962 for the removal commit. ### Before you submit your PR Make sure the following is true before submitting your PR: - [ ] I have read the [contributing guidelines](https://github.com/livekit/rust-sdks/blob/main/CONTRIBUTING.md) and validated that this PR will be accepted. - [ ] I have read and followed the principles regarding breaking changes, testing, and code quality. ### PR description Describe the changes in this PR. Explain what the PR is meant to solve and how to reproduce the issue in the first place. ### Breaking changes If this PR introduces breaking changes, list them here and document the rationale for introducing such a change. ### MSRV If the PR modifies the crate's MSRV (Minimum Supported Rust Version), document it here. ### Testing Ideally, unit test the code you add, but ensure you're not repeating existing test cases. Use as many already written scaffolding, utilities as possible; write your own, when needed. If external services, APIs, tokens are required (e.g., running an LK server instance), provide the necessary information. Make sure your tests perform useful, context-aware assertions and do not simply emulate "happy paths". ### Async We want the project to be runtime-agnostic, so please reuse what's already in [livekit-runtime](https://github.com/livekit/rust-sdks/blob/main/livekit-runtime/) and feel free to add anything missing. It's ok to use Tokio directly, when writing unit tests, if necessary. When testing, do not use artificial delays for the state to "catch up"; instead, respect the event flow and subscribe properly using channels or other mechanisms.
1 parent 0067e10 commit 614c99a

23 files changed

Lines changed: 2607 additions & 1704 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
livekit-net: minor
3+
livekit-api: major
4+
livekit: major
5+
livekit-ffi: patch
6+
livekit-uniffi: patch
7+
---
8+
9+
Route LiveKit signalling through a pluggable transport (new `livekit-net` crate).
10+
11+
The signalling WebSocket and the two pre-connect HTTP GETs (validate, region discovery) now go through pluggable transport traits (`WsClient` for the WebSocket, `HttpClient` for request/response) resolved from a process-global registry with independent slots — a consumer can bring only HTTP, or only WebSocket. The new `livekit-net` crate owns the WebSocket/HTTP/TLS stack behind those traits and ships native (tokio / async-std) backends. Native builds are unchanged in behavior.
12+
13+
**Breaking (`livekit-api`, and `livekit` via `EngineError::Signal`):**
14+
15+
- `SignalError::WsError` is removed — `tungstenite` is no longer part of the public API. A failed WebSocket handshake now surfaces its HTTP status as `SignalError::Client`/`Server`; transport connection and close failures surface as the new `SignalError::Connection(String)` / `SignalError::Closed` variants (previously all collapsed into `Timeout`).
16+
- `SignalError` is now `#[non_exhaustive]`, and gains a `SignalError::TransportNotConfigured` variant — returned when no transport is registered (host/foreign builds must call `livekit_net::set_ws_client` / `set_http_client` before connecting). This is a permanent configuration error; callers must not retry.
17+
- The signalling WebSocket/HTTP/TLS crates are no longer transitive dependencies of `livekit-api`; TLS features delegate to `livekit-net`. Existing `signal-client-tokio` / `-async` / `-dispatcher` and TLS feature names are unchanged.

.github/workflows/tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,10 @@ jobs:
162162
--features __lk-e2e-test \
163163
-- \
164164
--nocapture \
165-
--test-threads=1
165+
--test-threads=1
166+
167+
- name: Test transport seam (livekit-net / signal-client)
168+
shell: bash
169+
run: |
170+
cargo test --verbose --target ${{ matrix.target }} -p livekit-net --features native-tokio
171+
cargo test --verbose --target ${{ matrix.target }} -p livekit-api --features signal-client-tokio

0 commit comments

Comments
 (0)