-
Notifications
You must be signed in to change notification settings - Fork 62
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
VSCODE-311: new data service and connection model #377
VSCODE-311: new data service and connection model #377
Conversation
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.
Nice work! Took a first look at everything, but I think I’ll need to spend a bit more time before I can say that I fully follow the data flow everywhere :)
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.
Looks good! I left a few more comments, but they are mostly non-blocking, and in any case, nothing larger.
One thing I’m curious about: Is there a specfic reason for keeping the connections in memory in ConnectionController._connections
, instead of always accessing them through the storage API? I’m not saying we should change this, I’m just wondering 🙂
src/connectionController.ts
Outdated
newConnectionModel | ||
); | ||
parseNewConnection(rawConnectionModel: RawConnectionModel): ConnectionInfo { | ||
const connectionModel = new ConnectionModel(rawConnectionModel); |
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.
I guess this is the part where we’re not sure about whether it’s alright to keep going with ConnectionModel
? I would think it’s okay, yeah. We should probably just leave a ticket about eventually removing it. (But it might be nice if @Anemy could confirm this 🙂)
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.
I think it's fine yup. It's probably not worth adding all the logic to build the connectionInfo from the connection configuration object the form in the webview creates. Would be nice to remove this usage of connection-model eventually, and this would definitely be something that sharing the connect form would help make go away as well.
return 'MongoDB connection strings begin with "mongodb://" or "mongodb+srv://"'; | ||
try { | ||
// eslint-disable-next-line no-new | ||
new ConnectionString(uri); |
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.
I like this change, but I'm wondering if the old one, although not as good of a validation check, might give a user unsure what to enter in something more information to help their case.
Mostly if they input something like a url but is invalid they'd get an Invalid connection string
error message which doesn't hint at what might go there. https://github.com/mongodb-js/mongodb-connection-string-url/blob/main/src/index.ts#L106
Maybe something for that package instead of here. We do have a placeholder here that should give those users something to go off of so this may be a non-issue.
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.
@addaleax what do you think?
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.
I can definitely see the concern here – if you want to keep the previous check additionally (i.e. add
if (!uri.startsWith('mongodb://') && !uri.startsWith('mongodb+srv://')) {
return 'MongoDB connection strings begin with "mongodb://" or "mongodb+srv://"';
before the new ConnectionString
check), I think that’s okay and won’t make anything worse, but I also honestly think that this isn’t something we need to worry about a ton, and I do agree with @Anemy that it would be a bit nicer to improve the error message inside the connection string url package as a long-term solution 🙂
@addaleax Answering your question why we keep connections in memory: first of all, I didn't change this logic in this pr, this worked like this before. But was thinking about it while refactoring and kept like this because of two reasons:
We also discusses it with Maurizio and as I remember he was also up to pulling them all together. I am open here for a discussion if you have a strong opinion to do it differently! |
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.
nice work - big changes that touch almost all the extension. Solid cleanup on the language server.
@@ -106,44 +80,18 @@ export default class ConnectionTreeItem extends vscode.TreeItem | |||
return element; | |||
} | |||
|
|||
async listDatabasesUserHasAccessTo( |
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.
Cool that we're sharing this with compass now 👍
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.
Yes! I was very excited to see this change in compass and know the fact that we can reuse it in vscode!
Description
Switch to a new connection info format. The new data service is using a new connection info object that should be adopted by the extension and used to connect and save connections.
VSCode should start using a new connection info object for the saved connections including migration of previously saved connections to a new format and using the
connection-secrets
module from Compass to protect all secrets.I also removed LSP inspector since the webview extension is buggy and doesn't work almost all the time.
It also fixes #383.
Checklist
Motivation and Context
Dependents
Dependent on mongodb-js/compass#2650
Types of changes