This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
Implement Tokio-based LSP client (for testing) #1223
Merged
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.
Based on #1210.
The original motivation for this work was to tackle the recent spurious failures and make sure there are no timing/racing issues, at least on the testing harness side for
rls
spawning integration tests, so this is an attempt that does not spawn a thread and without explicit sleeping, but instead runs on the current thread (Tokio runtime), uses async I/O to read the messages and can block the current thread until specified message arrives.Thanks to RLS lib being exposed, this also can send typed requests; due to notification model we block on the response and return it as part of the request function call (so it's an actual RPC) and we can naturally add timeouts per each message.
At first I wanted to only work with
mio
instead but I found myself trying to write a lot of scaffolding that's been already implemented as parts of Tokio andmio-named-pipes
, so I figured I'll pull in Tokio instead (many of the transienttokio-*
deps aren't needed, there's work going at tokio-rs/tokio#808 to make these optional).I'd say this was a good excuse to finally look at the async (ecosystem) in Rust! Given enough polish maybe it'd make sense to extract the async LSP client into separate crate?
@alexheretic @nrc I'd very much appreciate taking a look at it!
Also a shout out to @alexcrichton for mio-named-pipes and tokio-process, which made this use-case a breeze 😁
EDIT: Ported only a single test, can rewrite rest of this as a part of this PR or later if looks good enough.