Add TCP support to pygls' LanguageClient#501
Merged
Merged
Conversation
This commit promotes the `JsonRPCProtocol._procedure_handler` and `JsonRPCProtocol._deserialize_message` methods to be public methods. It also renames them to `handle_message` and `structure_message` respectively.
Given any `asyncio.StreamReader`, it should be possible to create a main async message handling loop over a compatible transport.
This allows pygls' LanguageClient to communicate with servers over a TCP connection
This fixes coverage reporting, but has the chance for the process to hang. This can be worked around by using `asyncio.wait_for()` ```python await asyncio.wait_for(client.stop(), timeout=5.0) # seconds ```
This takes the simple cli wrapper from the example `json_server.py` and puts it into a new `pygls.cli` module. The wrapper makes it easier to select which transport mechanism the server should use. It's primary intention is simply to reduce the amount of boilerplate required to start one of the example servers
This extends pygls' test suite with a `--lsp-transport` command line argument. - `--lsp-transport stdio` (the default), runs the end-to-end tests over stdin/stdout. - `--lsp-transport tcp`, runs the end-to-end tests over a TCP connection The `poe test` task used in CI has been updated to run both style of end-to-end tests.
e716b74 to
b84f7bd
Compare
f20f96f to
be62b54
Compare
Collaborator
Author
|
Running the end-to-end tests over TCP has highlighted an interesting bug (#502). Since it isn't really related to the client's new TCP capability I've skipped the test for now and we can figure out a fix for it separately - who knows maybe future server side refactorings will magically fix it? 😅 🙏 |
Collaborator
Author
|
Thanks! |
6 tasks
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.
Description (e.g. "Related to ...", etc.)
This PR adds a
start_tcpmethod to pygls'LanguageClient. This method uses the high-level asyncio APIs I would like to transition the server side over to using (as mentioned in #334).However, before touching the server-side code I thought it would be best to add tests around the current implementation. So this PR also extends pygls' test suite to add a
--lsp-transportcommand line argument.--lsp-transport stdio(the default), runs the end-to-end tests over stdin/stdout.--lsp-transport tcp, runs the end-to-end tests over a TCP connectionThe
poe testtask used in CI has been updated to run both style of end-to-end tests.Finaly, this PR also includes some smaller client related fixes
Code review checklist (for code reviewer to complete)
Automated linters
You can run the lints that are run on CI locally with: