-
Notifications
You must be signed in to change notification settings - Fork 200
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
Generic path to create specific SqlConnectOptions #644
base: master
Are you sure you want to change the base?
Conversation
Rather name than kind |
I think I chose Some other options to consider:
|
I believe the correct naming to use here is |
So @vietj you are suggesting What about |
vendor name is different, one vendor can have several databases.
DBMS looks very fine to me and something that everybody understand as it has been around for a few decades.
… On 26 May 2020, at 16:35, Andrew Guibert ***@***.***> wrote:
So @vietj <https://github.com/vietj> you are suggesting setRDBMS(String)? To me that doesn't imply that we are just setting the type name of the DB. Also, I'd like to keep longer acronyms out of the API.
What about setDatabaseDistributionName(String) or setDatabaseVendorName(String)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#644 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABXDCVA4M5RLMNOQMCYZJDRTPHTBANCNFSM4NFJBIQA>.
|
To me How about @BillyYccc any opinion on this one? To recap, the options currently proposed are:
|
How about simply |
|
two DBs might use the same protocol
… On 26 May 2020, at 18:14, Billy Yuan ***@***.***> wrote:
DatabaseProtocol is not a good choice because not all DB protocols are named by the database name such as TDS protocol for MSSQL Server.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#644 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABXDCRC2TWPT2GZ5PE4QLDRTPTIBANCNFSM4NFJBIQA>.
|
Sure, I like BTW, the reason I am trying to add this in the first place is so that a user can optionally specify the database type for situations where:
We need a way to disambiguate which driver to select (without having a direct dependency on the driver-specific API) |
given that the SPI for this is named Driver, it seems that using "driverName" or "driver" is a good fit.
… On 26 May 2020, at 18:13, Billy Yuan ***@***.***> wrote:
How about simply driverName? The database client indeed does not care about what the database server is as long as they're able to communicate with each other via a specific protocol. For example you can use PG client to connect with Postgres or other databases like Cockroach.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#644 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABXDCWMSYMIBZLW4VOENA3RTPTD5ANCNFSM4NFJBIQA>.
|
I think actually that an overload with the driverName would work better.
static Pool pool(String driverName, SqlConnect options) { ... }
The SqlConnectOptions describe how to connect to the database (i.e coordinates) and not to which database it should be connected
… On 26 May 2020, at 18:17, Andrew Guibert ***@***.***> wrote:
Sure, I like setDriverName(String).
BTW, the reason I am trying to add this in the first place is so that a user can optionally specify the database type for situations where:
Multiple drivers are on the classpath
Generic properties config are used (i.e. host/port/user/etc)
We need a way to disambiguate which driver to select (without having a direct dependency on the driver-specific API)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#644 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABXDCQL7XL4RGSDCTGVT73RTPTTPANCNFSM4NFJBIQA>.
|
Ok, sounds like we all agree on As for where to specify it, |
@aguibert I agree for the overloading, another way would be to have a static method that creates |
It seems that using plain In order to fix the driver name and the reported issue, we need to have This will solve this PR and the issue #660 issue. |
If we add the static method for I suppose we could add the new |
On 27 May 2020, at 16:42, Andrew Guibert ***@***.***> wrote:
If we add the static method for Driver.connectOptions("mysql"), does that imply we would want to turn SqlConnectOptions back into an abstract class then? Otherwise we're not solving the issue for all cases. However, this would be a breaking change that we couldn't make until 4.0.
I suppose we could add the new Driver.connectOptions now, and then turn SqlConnectOptions abstract in 4.0?
yes that would work great
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#644 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABXDCVAR7FNKPL7LHCXWJ3RTURDRANCNFSM4NFJBIQA>.
|
Also deprecate generic construction of SqlConnectOptions
…ions is the only generic path
@vietj ok, I've reworked the PR based on your feedback. I removed the SqlConnectOptions opts = Driver.createConnectOptions(KnownDrivers.DB2);
Pool pool = Pool.pool(opts); |
@@ -27,6 +35,71 @@ | |||
*/ | |||
public interface Driver { | |||
|
|||
public static enum KnownDrivers { |
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.
this creates an implicit dependency (yet weak) from sql-client onto the existing implementations. We are actually going to have a JDBC implementation as well that will not be in this GitHub repository, so I think it would be best better to avoid this and have instead each driver define a string constant for 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.
When we add a JDBC implementation in a separate repo we can add another value to this enum, right?
Any other drivers that come along will still work, and will ultimately be able to define what they want their string constants to be.
Mainly I'm just going for user-convenience here by adding "knowledge of" the known implementations, I don't know if you could really call it a dependency
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.
there isn't much a point of having KnownDrivers
enum than having a glorified factory, i.e
if you write
SqlConnectOptions options = Driver.createConnectOptions(Driver.KnownDrivers.POSTGRESQL)
then you can simply write
SqlConnectOptions options = new PgConnectOptions();
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 was mainly looking at this from a UX perspective, but since this is just the SPI path (not API) UX is less important because users won't be doing this directly.
I'll go ahead and remove the KnownDrivers
enum and associated code
Any further comments on this one @vietj or are we good to merge? |
@@ -27,6 +33,44 @@ | |||
*/ | |||
public interface Driver { |
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 need to add VertxGen
annotation to make it work for ReactiveX/etc...
@@ -46,6 +47,7 @@ | |||
* @return the connection pool | |||
* @throws ServiceConfigurationError if no compatible drivers are found, or if multiple compatible drivers are found | |||
*/ | |||
@GenIgnore |
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.
can we remove these @GenIgnore
annotations ?
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.
The build was failing saying these were not supported, I can go back and check again, but the whole generation step is an enigma to me
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.
could you push the branch to the upstream repo so that we could try to build that and see what happens?
This improves the driver API so that a specific DB type can be requested using the generic SqlConnectOptions path. This is necessary for situations when A) user does not want a direct dependency on the driver API and B) there may be multiple different drivers on the classpath.
Example usages: