-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TCP support to pygls' LanguageClient #501
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
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? 😅 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work.
Thanks! |
Description (e.g. "Related to ...", etc.)
This PR adds a
start_tcp
method 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-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 connectionThe
poe test
task 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: