Better encapsulate livekit-runtime using a new Runtime trait - #1369
Closed
1egoman wants to merge 7 commits into
Closed
Better encapsulate livekit-runtime using a new Runtime trait#13691egoman wants to merge 7 commits into
livekit-runtime using a new Runtime trait#13691egoman wants to merge 7 commits into
Conversation
…ends: async_std and dispatcher
The asynd_std TcpStream is re-exported by smol. Since that doesn't clearly fit into a "runtime" grouping cleanly anymore, make livekit-net own this. That also I think breaks out the last dependency that would keep livekit_runtime::set_runtime from working cleanly.
Contributor
Author
|
Closing in favor of #1375 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
The
livekit-runtimecrate was introduced in ~2024 by the folks at zed so they could uselivekitin zed, which wasn't using a tokio runtime (my understanding is, a completely custom runtime!). The general design patterns haven't really changed since then.However, a few pain points that have been encountered recently touch on
livekit-runtime:tokio::fsusage in thesend_filedata stream method. These could be fixed piecemeal, but we'd need to extend the abstractions further to deal with a bunch of different async operations which is fairly burdensome.asyncanddispatcherfeatures (what zed was using specifically) don't actually build onmainproperly 😞 .livekit-runtime(which isn't super well encapsulated - higher level features in thelivekitcrate sometimes imply certain runtimes), it would be challenging. We'd have to effectively do a build for eachplatformxruntimexssl configurationx any ad hoc features which is impractical.From what I can tell looking through zed's code, they seem to have since migrated from the custom runtime approach they were using to a more typical looking tokio backed approach. It also looks like they might be using a rust-sdks fork, not actually mainline. I've done a search across all of github, and the only places that
dispatcherseems to be used is by stale zed forks, so I'm fairly confident this can be dropped with little to no consequence.Work in progress design
Update the
livekit-runtimecrate to instead expose a newRuntimetrait, mirrored after the way theFuturetrait in the futures crate works:Then, a series of implementers are exposed as
TokioRuntime,AsyncStdRuntime, and (newly added)SmolRuntime. Each implementsRuntime- for example:By default,
TokioRuntimeis used. If a user wants to change runtime, they callset_runtimebefore using the sdk:This also leaves the door open to custom runtimes still via implementing
Runtime. In addition, for extra behaviors (for example, filesystem logic), there would be relevant extension traits - for example:Open questions
dispatcheris not not being used by zed and bothasync/dispatcherdon't compile onmain, would it be better to droplivekit-runtimeall together and go back to this crate being tokio only?TODO
dispatcheris no longer usedlivekit_runtime.