Support for large RPC messages using data streams#1013
Support for large RPC messages using data streams#1013
Conversation
ChangesetThe following package versions will be affected by this PR:
|
| // ========================================================================= | ||
| // v2 -> v2 tests (both sides support data streams) | ||
| // ========================================================================= | ||
|
|
||
| /// Spec #1: Caller happy path (short payload) — v2 data stream used. | ||
| #[tokio::test] | ||
| async fn test_v2_v2_caller_happy_path_short() { | ||
| let client = Arc::new(RpcClientManager::new()); | ||
| let transport = Arc::new( | ||
| MockTransport::new() | ||
| .with_remote_protocol("dest", CLIENT_PROTOCOL_DATA_STREAM_RPC), | ||
| ); | ||
|
|
||
| let handle = spawn_perform_rpc( | ||
| client.clone(), | ||
| transport.clone(), |
There was a problem hiding this comment.
Note to any reviewers: The tests here don't use the larger e2e test infrastructure in this repository purposely, because some test need to fully emulate the behavior of an old client (ie, doing things like always sending RpcRequest / RpcResponse even with a newer client_protocol, etc).
I am not sure if this is a good idea or not. Halfway through the process, the LLM basically said it couldn't generate the tests with the e2e infrastructure and proposed this as an alternative so I let it go for it.
There was a problem hiding this comment.
There's also been some divergence for the single peer connection tests; in a follow-up, we should ensure all the E2EE tests are using common testing utilities (and make sure they can support any configuration needed by the test), but I would say for now it's better to include the tests even if they use different infrastructure.
| /// Override the client_protocol advertised during join. If `None`, falls back | ||
| /// to `CLIENT_PROTOCOL_DEFAULT` (0). The SDK's default constructor sets this | ||
| /// to `CLIENT_PROTOCOL_DATA_STREAM_RPC` (1) to advertise data-stream RPC support. | ||
| pub client_protocol: Option<i32>, |
There was a problem hiding this comment.
Nit
why not just make it a i32 and default to 0 , rather than optional
There was a problem hiding this comment.
Looking at this again, I don't really understand why this even has to be a struct member. I think it should match the js implementation and just be a constant called something like ADVERTISED_CLIENT_PROTOCOL. Updated to use this constant approach instead in 4e63807.
| &data.payload, | ||
| effective_timeout, | ||
| ) | ||
| .await |
There was a problem hiding this comment.
I don't think this is needed - send_v2_request's returned error type is RpcError, and perform_rpc (the function this is in) returns Result<String, RpcError>.
|
|
||
| // RPC protocol version constants (distinct from client_protocol; this is the | ||
| // version field on RpcRequest / v2 stream attributes). | ||
| pub(crate) const RPC_VERSION_V1: u32 = 1; |
There was a problem hiding this comment.
This should be able to able to be incremented beyond two values, so I think keeping it some kind of uint makes sense.
| Self { handlers: Mutex::new(HashMap::new()) } | ||
| } | ||
|
|
||
| pub fn register_method( |
There was a problem hiding this comment.
suggestion: I have a WIP PR (#858) to allow RPC method registration prior to room connection. I haven't merged this yet since the FFI portion is incomplete and requires some larger architectural changes, but the core change in the livekit crate is finished and could potentially be integrated here.
There was a problem hiding this comment.
Nice! There's enough conflicts on that linked pull request where I think it probably makes more sense to integrate these as part of inevitably fixing the merge conflicts when that pull request is rebased.
| // ========================================================================= | ||
| // v2 -> v2 tests (both sides support data streams) | ||
| // ========================================================================= | ||
|
|
||
| /// Spec #1: Caller happy path (short payload) — v2 data stream used. | ||
| #[tokio::test] | ||
| async fn test_v2_v2_caller_happy_path_short() { | ||
| let client = Arc::new(RpcClientManager::new()); | ||
| let transport = Arc::new( | ||
| MockTransport::new() | ||
| .with_remote_protocol("dest", CLIENT_PROTOCOL_DATA_STREAM_RPC), | ||
| ); | ||
|
|
||
| let handle = spawn_perform_rpc( | ||
| client.clone(), | ||
| transport.clone(), |
There was a problem hiding this comment.
There's also been some divergence for the single peer connection tests; in a follow-up, we should ensure all the E2EE tests are using common testing utilities (and make sure they can support any configuration needed by the test), but I would say for now it's better to include the tests even if they use different infrastructure.
|
Postponing my review until 1832. |
d37f3ae to
3980b10
Compare
It doesn't need to be drilled through as an option, it's fundamentally tied to the broader code context it is part of.
|
I think the code in general looks clean and easy to follow for me. what is the plan of landing it ? |
This should match PROTOCOL_VERSION.
|
@reenboog FWIW, the plan was to merge this and livekit/client-sdk-js#1832 at the same time - I don't want to get into the situation where the web version gets merged and this one gets blocked for a while and then it's a web only feature. Also, holding off on merging the web one means we can make protocol updates to v2 which are non backwards compatible during the review, if required. So, feel free to take a look at this now. |
This is easier to follow and matches better with how the v2 version works
…anager as methods
|
In regards to all the ci failures - this looks to be a github problem, NOT a problem with this branch. See here for another example of this I'll rerun these in a few hours and hopefully this is transient / that will fix it. |
This is port of the identically named client-sdk-js pull request livekit/client-sdk-js#1832, adding support for RPC protocol version 2, via feeding the spec to a LLM.
Warning
This pull request was LLM generated and has only been lightly reviewed by a human. The author has tested this and confirms it works in the happy path, but no other validation has been done.
A more thorough review of this needs to occur before it could be merged. The plan is to hand this off to a rust sdk maintainer to get it fully across the line.