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

check datastore connectivity after registering it #1621

Merged

Conversation

bhargavkn
Copy link
Contributor

@bhargavkn bhargavkn commented Sep 28, 2021

Changes in this PR attempt to resolve balderdashy/sails#7095 by making waterline validateConnection for a datastore after it has been registered. This will make waterline return an error if a datastore was registered but waterline's attempt to validate the connection failed.

@bhargavkn
Copy link
Contributor Author

@eashaw may I please have your review on this PR? 🙇

lib/waterline.js Outdated
}

// Check if the datastore adapter has a `validateConnection` method
if (_.has(datastore.adapter, 'validateConnection')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you instead use getConnection and releaseConnection adapter methods (you'll still need to check if they both exist)
Heres an example of how you can access the manager
https://github.com/balderdashy/sails-hook-orm/blob/9c2a3c768eba152e47af645d02462ed831f87dbb/lib/build-registered-datastore-instance.js#L116

Copy link
Contributor Author

@bhargavkn bhargavkn Oct 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eashaw The idea here was to move the operations on connection objects (Such as getConnection and releaseConnection which are more common in the SQL realm and might not be applicable in other cases) away from waterline (and the orm hook) and keep it contained within the adapters (as done in balderdashy/sails-postgresql#290). This way each adapter can be more flexible in terms of how it wants to validate connectivity and waterline needn't be concerned with the implementation details of how connectivity to a datastore is to be validated. This is my opinion though, Let me know if you still want me to change this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bhargavkn, good news! getConnection and releaseConnection are standard across Waterline adapters, relational or not. https://github.com/node-machine/driver-interface/tree/e44cb443ae5cb16fdb824dc0a5bec3996563b1e1#connectable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, will push the changes shortly. Thanks for sharing the doc.

@bhargavkn bhargavkn force-pushed the feature-test-datastore-connectivity branch from ac1fe33 to a7a5a6d Compare October 14, 2021 17:29
@bhargavkn bhargavkn force-pushed the feature-test-datastore-connectivity branch from a7a5a6d to 3b64561 Compare October 14, 2021 17:32
@bhargavkn
Copy link
Contributor Author

@eashaw Does this seem better?

@bhargavkn
Copy link
Contributor Author

@eashaw Please let me know in case there are any pending action items on my part in order to merge this 🙇

@eashaw eashaw merged commit 55d0bcd into balderdashy:master Oct 22, 2021
@bhargavkn bhargavkn deleted the feature-test-datastore-connectivity branch October 22, 2021 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Better error message for bad postgres config
2 participants