-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support creating a driver directly without registering it #3
Conversation
In some cases it's useful to reuse drivers to prevent leaking drivers every time a connection is opened. This allows library users to register the driver themselves and reuse the registered name when necessary.
Thanks for the 3 PRs! Glad to see someone else is using go-athena. I'll review shortly. |
@sirwart This whole register ordeal feels hacky, but leaking drivers seems like a real problem if your app is connecting to lots of "Athenas" (e.g. a BI platform). Just to clarify, does the following snippet reflect how you intend to use this? driver := athena.NewDriver()
sql.Register("athena", driver)
// do stuff with driver
// later,
newDriver := athena.NewDriveR()
*driver = *newDriver Mind adding a godoc comment about reusing the Driver, as this trick may help others, too? |
Probably need a different name for that to work, otherwise you'd be calling register twice (once from your snippet and once from the init) twice which panics. https://godoc.org/database/sql#Register |
Thanks Tejas, this driver helped me get going a lot faster than otherwise. My solution for avoiding leaking is to register as
|
@sirwart That makes sense. Thanks for the context. I'm afraid Regardless, let's go ahead and merge this in. |
Yea, good point. If you decide to go the adding options route, it'd probably be good to include region in addition to the AWS key/secret which would cover all the basics needed to connect to Athena. The only other thing I can think of are the encryption options, but I haven't had to deal with them yet. |
In some cases it's useful to reuse drivers to prevent leaking drivers every
time a connection is opened. This allows library users to register the driver
themselves and reuse the registered name when necessary.