Short Term DSN for database/sql

151 views
Skip to first unread message

agru...@gmail.com

unread,
Nov 7, 2017, 8:34:20 AM11/7/17
to golang-nuts
It appears the Generic Interface for SQL (database/sql) does not support the ability to use short lived DSN's for cases like AWS's IAM Authentication to RDS instances. It appears that when doing its connection pooling activities it always uses whatever DSN was passed initially on Open.

1) Is this correct.
2) Assuming one is correct would the Golang project every consider adding this feature?
3) If the answer is yes. How would one go about either helping to get it on the road map or better yet contributing this feature back to the community? What is this process?

Thanks,
Anthony Gruetzmacher

Konstantin Khomoutov

unread,
Nov 7, 2017, 10:22:00 AM11/7/17
to golang-nuts, agru...@gmail.com
Does setting the maximum number of the idle (that is, pooled) database
connections [1] to a value equal or less than zero helps with this?

1. https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns

agru...@gmail.com

unread,
Nov 7, 2017, 12:11:40 PM11/7/17
to golang-nuts
This does not help because if there is no connection in the connection pool the interface will open a new connection with previously supplied DSN from the sql.Open call.

Anthony

Daniel Theophanes

unread,
Nov 7, 2017, 12:44:05 PM11/7/17
to golang-nuts
Go1.10 will ship with a driver connector https://tip.golang.org/pkg/database/sql/driver/#Connector . It would be possible for a driver to provide a callback function that returned the most recent authentication parameters by using that.

Thanks, -Daniel

agru...@gmail.com

unread,
Nov 9, 2017, 12:09:50 PM11/9/17
to golang-nuts
So this would allow for the driver to support a different method of opening the connection that the sql interface would use when it needed to open a new connection correct?

Anthony

Daniel Theophanes

unread,
Nov 9, 2017, 1:49:00 PM11/9/17
to agru...@gmail.com, golang-nuts
It allows drivers a way to provide a connection to the pool on demand, without needing to go through a static connection string.

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/fl0GiIEmbLM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

agru...@gmail.com

unread,
Nov 9, 2017, 4:18:59 PM11/9/17
to golang-nuts
What would happen if idle/closed connections that are in the SQL interface's connection pool? They go back to the driver provided Connector interface to re-authenticate/create a connection?

Thanks,
Anthony

Daniel Theophanes

unread,
Nov 9, 2017, 4:45:14 PM11/9/17
to agru...@gmail.com, golang-nuts
I don't quite understand you question. It just allows drivers an alternate way for the pool (sql.DB) to open a connection. Nothing ever is "returned".

agru...@gmail.com

unread,
Nov 9, 2017, 5:04:05 PM11/9/17
to golang-nuts
Makes sense. I think my question was more asking about the details of how the pool (sql.DB) worked. So this clears it up. The driver would provide the pool this connector to use vs the DNS string and that Connector could re-auth etc... This definitely allows for what I am looking for to be solved. The next step would be to get an IAM Connector added into the driver. Anyway thank you for the response very helpful.

Anthony
Reply all
Reply to author
Forward
0 new messages