-
Notifications
You must be signed in to change notification settings - Fork 163
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 addon client and server base classes #2501
base: main
Are you sure you want to change the base?
Conversation
36ea722
to
d997d70
Compare
145b51d
to
dcb2257
Compare
This commit introduces two new classes to enhance the addon framework: 1. ProcessClient: Manages communication with addon servers, handling initialization, message sending/receiving, and shutdown. 2. ProcessServer: Provides a base class for addon servers to handle requests and responses. These classes facilitate better separation of concerns and provide a structured approach for addons to communicate with the Ruby LSP server.
dcb2257
to
d578615
Compare
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
require "sorbet-runtime" |
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.
We had some issues in the past when requiring sorbet-runtime
within the Rails side. I can't recall the exact cause, but we might need to be wary of that or do some extra checking.
@running = false | ||
{ result: {} } | ||
else | ||
VOID |
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.
We shouldn't need the VOID
stuff any more now that Shopify/ruby-lsp-rails#453 is merged.
FYI, I'll update this after Tapioca LSP is merged. |
Motivation
The client/server architecture of
ruby-lsp-rails
to a large degree can be adopted by many other addons too. For example, other web frameworks, like Hanami, can also use it to provide runtime information. And if we extract the base client/server implementation intoruby-lsp
, it'll make such applications easier to implement.Also, through such extraction we can standardize things like:
And that will make
ruby-lsp-rails
easier to maintain and understand as well.Draft PR from
ruby-lsp-rails
: Shopify/ruby-lsp-rails#439Implementation
RubyLsp::Addon::ProcessClient|ProcessServer
classes. To use them, addons should requireruby_lsp/addon/process_client
in the client file andruby_lsp/addon/process_server
in the server file.process
prefix with the hope to indicate that they're only needed when the addon needs to interact with another process.Automated Tests
I added a new
test/addon/process_client_server_test.rb
with a fake addon to test the client and server end-to-end.Manual Tests