Skip to content
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

Prototyping a runtime strategy to allow different runtime behaviours in the language server #247

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

daveajrussell
Copy link
Collaborator

Currently with our vscode extension, we have 2 instances on the schema poller.. 1 in the vscode extension, that is used for connecting to and listing databases and their properties. The other is in the language server itself, and is used by the language server for database aware features.

The vscode extension brokers messages via the language client for language server to update its own schema poller instance when the connection in the extension is modified.

There are a few problems with this approach;

  • we are opening more connections than are necessary to a neo4j instance
  • the drivers may individually become unhealthy, leading to the schema pollers falling out of sync

In this prototype I am;

Creating the concept of a 'Runtime' in the language server
This does make the language server somewhat less client agnostic, as this approach makes it aware of the client that is consuming it.

However it does allow us to configure the language server to manage its own instance of the schema poller, or allow schema updates to be deferred to the consumer.

In the standalone runtime, we construct a schema poller instance and establish a persistent connection to it.

In the extension runtime, we establish a single listener to a schemaFetched message, that updates an internal dbSchema instance which the database aware features will use. This message will be dispatched from the vscode extension when it receives an event from its schema poller instance.

schema poller:emit('schemaFetched') -> vscode extension:languageServer.sendNotification('schemaFetched', {}) -> language server:onNotification('schemaFetched', (dbSchema) => {})

It would be nice to share the actual schema poller instance that the vscode extension creates between the vscode extension and the language server to avoid the need for having to rebroadcast a message from the extension, but this does not seem possible.. parameters may be passed via the initializationOptions, however these are serialized and deserialized, and the event emitter doesn't pick up messages inside of the language server.

Copy link

changeset-bot bot commented Jul 25, 2024

⚠️ No Changeset found

Latest commit: a5795da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@OskarDamkjaer
Copy link
Collaborator

I like this approach/solution to the problem, I feel it makes it simpler to understand how the connection to neo4j works 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants