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
Driver name collision #151
Comments
I think the best way to go here is build tags. Specify different libraries in different files and use tags. |
@DoubleDi could you provide short example how to use mailru/go-clickhouse anc clickhouse/clickhouse-go on the same application on runtime? |
@Slach not sure that is possible. As both libraries register same driver name. We can patch the lib, so it will support that using build tags or envs. Why is it necessary to use 2 libs at the same time? |
To be able to provide connection to a ClickHouse despite how and where it was deployed. For example: We have ClickHouse at an external Kubernetes environment with Ingresses, configured only to provide an HTTP connection. Also, we have an internal ClickHouse with prepared TCP ports, for connections using native driver. And I, as a common connection provider library developer, want to deliver a flexible solution. To give an end-user opportunity to choose connection type on the fly, and not to worry much about environments' settings, using this library. |
In the beginning, I've asked about that at StackOverflow and some of the community members agreed that using both of these libraries at the same time might be useful: https://stackoverflow.com/questions/70683405/choose-an-sql-driver-at-runtime-in-golang-when-drivers-have-the-same-name |
We can try to register the driver additionally by the name of |
At least we'll be able to create an interface with methods, which will cover end-user needs without using specific data types and add two implementations that operate with different libs. Then we can provide a method that will return connection instances depending on the environment variable. |
@myserg unfortunately, we cannot just change the name of the driver, as this would break all the current driver integrations. One of the solutions is make a v2 driver version. The second solution looks simple. What do you think? |
It's just a key in the global unexported map, how it could possible break anything? (https://cs.opensource.google/go/go/+/refs/tags/go1.17.6:src/database/sql/sql.go;l=44). Anyway, I've just written a simple HTTP bulk writer, one less user for your driver. |
Most of the current users use this library as
If we change the driver name to This means that we can't change the name without bumping a major version of the driver. We can achieve that by introducing v2. We can also try to introduce a hack using build tags, which I described. Is compiling your app with the Also if you have any other suggestions, that doesn't break the current user's experience let's discuss it or just make a PR. |
Hi, i am facing same issue, i think introducing v2 is the better way. the build tag way will limit the usage. Thank you. |
Please check if the current solution works for your usecase |
In our solution, we want to switch between
mailru/go-clickhouse
and native TCP ClickHouse driverClickHouse/clickhouse-go
using an environment variable for better compatibility and ease of development and deployment. But we can't do that because of the driver's name. They are the same and that's causespanic: sql: Register called twice for driver clickhouse
.Does anyone else think that this is an issue? Or maybe there is another solution?
The text was updated successfully, but these errors were encountered: