{"action":"created","issue":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/1053","repository_url":"https://api.github.com/repos/jinzhu/gorm","labels_url":"https://api.github.com/repos/jinzhu/gorm/issues/1053/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/gorm/issues/1053/comments","events_url":"https://api.github.com/repos/jinzhu/gorm/issues/1053/events","html_url":"https://github.com/jinzhu/gorm/issues/1053","id":158085740,"number":1053,"title":"Question on pooling/concurrency regarding recent documentation change, suggest clarification","user":{"login":"benguild","id":1185659,"avatar_url":"https://avatars.githubusercontent.com/u/1185659?v=3","gravatar_id":"","url":"https://api.github.com/users/benguild","html_url":"https://github.com/benguild","followers_url":"https://api.github.com/users/benguild/followers","following_url":"https://api.github.com/users/benguild/following{/other_user}","gists_url":"https://api.github.com/users/benguild/gists{/gist_id}","starred_url":"https://api.github.com/users/benguild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benguild/subscriptions","organizations_url":"https://api.github.com/users/benguild/orgs","repos_url":"https://api.github.com/users/benguild/repos","events_url":"https://api.github.com/users/benguild/events{/privacy}","received_events_url":"https://api.github.com/users/benguild/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-02T08:29:23Z","updated_at":"2016-06-02T08:38:49Z","closed_at":null,"body":"Myself and others were sort of unclear on how to correctly handle database connection pooling following more recent documentation changes. On older versions of the documentation, this phrasing was included:\r\n\r\n> Gorm is goroutines friendly, so you can create a global variable to keep the connection and use it everywhere in your project.\r\n\r\n`GORM` has since been updated, and this phrasing has been removed from the documentation, as has examples of using a global variable to store a single `*gorm.DB` object for the entire project at runtime.\r\n\r\nI personally opted to open a `*gorm.DB` object for each HTTP request, and hope that these connections were recycled from the connection pool in the SQL driver. From examining the code, this seems like the correct approach, but I wasn't sure if `GORM` handled this for us. **It looks like by using a global variable like before, GORM would share a single database connection for every single request to the application.** Maybe there's something I'm missing, but can someone clarify?"},"comment":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/comments/223230233","html_url":"https://github.com/jinzhu/gorm/issues/1053#issuecomment-223230233","issue_url":"https://api.github.com/repos/jinzhu/gorm/issues/1053","id":223230233,"user":{"login":"benguild","id":1185659,"avatar_url":"https://avatars.githubusercontent.com/u/1185659?v=3","gravatar_id":"","url":"https://api.github.com/users/benguild","html_url":"https://github.com/benguild","followers_url":"https://api.github.com/users/benguild/followers","following_url":"https://api.github.com/users/benguild/following{/other_user}","gists_url":"https://api.github.com/users/benguild/gists{/gist_id}","starred_url":"https://api.github.com/users/benguild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benguild/subscriptions","organizations_url":"https://api.github.com/users/benguild/orgs","repos_url":"https://api.github.com/users/benguild/repos","events_url":"https://api.github.com/users/benguild/events{/privacy}","received_events_url":"https://api.github.com/users/benguild/received_events","type":"User","site_admin":false},"created_at":"2016-06-02T08:38:49Z","updated_at":"2016-06-02T08:38:49Z","body":"What I don't understand specifically is that, using the global variable model, HTTP requests aren't passed into the DB wrapper. So, for database transactions, it seems like the requests could hit via multiple connections? Or does a transaction object save up all of the transactions and somehow fire them on a single connection?"}}
{"actor":{"display_login":"benguild"}}