pygls
pygls copied to clipboard
Sketching out a potential new architecture for pygls
As mentioned in #334, I don't think we need to base our JSON-RPC implementation on an asyncio.Protocol object anymore. Since all we have to to is read and write some bytes, I think it makes more sense to base it on high-level asyncio Reader and Writer objects instead.
I'm opening this PR (very!) early so that people have the chance to provide feedback, but bear in mind that there are still many details to consider! If it looks like this approach might pan out I will, of course, put some more effort into commit messages etc. so that it's more digestible.
I'd like to think that if this new approach proves successful, we can ship it alongside the current one so that people can opt-in to try it out
Goals
- Type annotate all the things!
- Draw stronger boundaries between responsibilities - the current
JsonRPCProtocoldoes a lot, including some details that are actually LSP specific - Have something ready to try when the next major
lsprotocolversion is ready - that way if this works out, server authors only have to deal with breaking changes once. - Clean up inconsistencies (#306)
- See if it's possible to not need "normal" and
_asyncflavours of every method. - Fix the pyodide tests once and for all
- WASM-WASI support (proof of concept here)
So far I only have a proof of concept working, where a JSON-RPC client is able to send a request to a simple JSON-RPC server and get a response.
Happy to elaborate further if needed, or even throw it all in the bin if it turns out to be a horrible idea!
TODO
- [ ] Implement stdio transport on Windows
- [x] Fix #433
- [ ] LSP Support
- [x] Autogenerated base server
- [x] Autogenerated base client
- [x] Updated feature manager
- [ ] Migrate built-in features
- [ ] Migrate to
lsprotocol 2024.x(#431)
- [ ] Other transports
- [ ] TCP
- [ ] Websockets
- [ ] Named pipes? (#403)
- [ ] Unix domain sockets #413
- [x] WASM-WASI support
- [ ] What would the migration story look like?
- [ ] Tests, tests and more tests
- [x] Fixed pyodide test suite #367
Code review checklist (for code reviewer to complete)
- [ ] Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
- [ ] Title summarizes what is changing
- [ ] Commit messages are meaningful (see this for details)
- [ ] Tests have been included and/or updated, as appropriate
- [ ] Docstrings have been included and/or updated, as appropriate
- [ ] Standalone docs have been updated accordingly