-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expose Conn - Request for Google App Engine #483
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
Comments
The reason is, in order to use Connection pooling with Google app engine, we need to do something like this as per #466:
What do we do here: db, _ := sql.Open("mysql", "id:password@external(your-amazonaws-uri.com:3306)/dbname") How do we ensure db will have |
Basically we need a way so that every There are some issues with above code when Right now, Google App Engine users must either use CloudSql OR use this driver without connection pooling on an non-cloudsql database. |
Perhaps, the driver provides a function where once |
@julienschmidt What do you think of a |
Where does the http.request come from in your callback? Who calls that from where? We don't have an http connection anywhere, |
Given that I assume many people use GAE (case in point: #484), and it is not unreasonable that some of those people would like to depart from cloudsql, and given that According to this: https://groups.google.com/forum/#!msg/google-appengine-go/FtWll9cYjmo/YoEZSJk_CgAJ there is a "proof-of-concept" workaround listed here:
The code above basically bypasses using Now regarding you points: I don't know the answer to those questions. I was listing the example code to highlight the pitfalls associated with getting a The I simply don't know how to do it - but I definitely think it will add value to this package given (I believe) how many people use GAE and how many would probably like to use an external database (with connection pooling) but can't due to this limitation. In GAE, everything revolves around the "Request" and the conversion of that request to a Context via |
It feel the proposed API is too dirty to keep backward compatibility forever, only for I would like to |
@pjebs it may be urgent, but I'm not interested in anything but the technical part of the issue. If you maintain projects I like and use and you write it's for one of them, I might just feel more eager to help. If you have a track record of answering to issues and providing support here, I'd be a lot more eager to help. But afaik, nobody who does active development here is getting payed for support or maintenance; being pressured and nudged is off-putting. If you propose a new api, it doesn't help if it cannot be used. In this case, we'd need the http connection. But if this is called from Open, that connection has to come from somewhere. And I don't know any code with access to it. As is, your example can reasonable be shortened to
because Open calls the dial function - if the callback would be called from there, the existing context would only be overridden. And the |
I'm going to attempt to create a wrapper around "database/sql" that will solve this problem by using an external pool. Is there a change that you can place a RW mutex around the |
I attempted to work around If anyone wants to help go ahead. |
@pjebs How would a mutex help? This is only written to from Register (usually called from init) and read from in Open. When would this clash, how do you want to use it? |
The reason why it was needed is because However, I figured out a way to put the mutexes on my side instead, so it's not needed anymore once i make the modifications to my wrapper. |
This is a very important feature request:
Can you please expose the
Conn
interface.When we call
sql.Open(...)
it returns asql.DB
struct. This is part of standard library so not much we can do about that.It is important however to get the underlying
Conn
for thesql.DB
. This can be done via this package (since it is also what sets it via custom dialer)URGENT FEATURE REQUEST
go-sql-driver/mysql
creates some kind of function that looks like this:When the user calls
sql.Open(...)
, then the driver callsregisterDialCallback( )
and uses the returned *net.ConnThe text was updated successfully, but these errors were encountered: