{"action":"created","comment":{"url":"https://api.github.com/repos/RangelReale/osin/pulls/comments/93583334","pull_request_review_id":14113260,"id":93583334,"diff_hunk":"@@ -47,3 +47,93 @@ type Storage interface {\n \t// RemoveRefresh revokes or deletes refresh AccessData.\n \tRemoveRefresh(token string) error\n }\n+\n+// Storage interface that takes a context object for database operations.\n+type StorageWithContext interface {\n+\t// Clone the storage if needed. For example, using mgo, you can clone the session with session.Clone\n+\t// to avoid concurrent access problems.\n+\t// This is to avoid cloning the connection at each method access.\n+\t// Can return itself if not a problem.\n+\tClone(ctx context.Context) StorageWithContext\n+\n+\t// Close the resources the Storage potentially holds (using Clone for example)\n+\tClose()","path":"storage.go","position":22,"original_position":22,"commit_id":"de482838e17ca3757aec966d6a1b54440c5ca4f4","original_commit_id":"de482838e17ca3757aec966d6a1b54440c5ca4f4","user":{"login":"mwitkow","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow","html_url":"https://github.com/mwitkow","followers_url":"https://api.github.com/users/mwitkow/followers","following_url":"https://api.github.com/users/mwitkow/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow/subscriptions","organizations_url":"https://api.github.com/users/mwitkow/orgs","repos_url":"https://api.github.com/users/mwitkow/repos","events_url":"https://api.github.com/users/mwitkow/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow/received_events","type":"User","site_admin":false},"body":"Close is usually done at the end of request. You definitely don't want that to be cancelled if the request timed out mid-way, you always want to free up resources. Also, this complies with:\r\nhttps://golang.org/pkg/io/#Closer","created_at":"2016-12-22T08:37:32Z","updated_at":"2016-12-22T08:37:32Z","html_url":"https://github.com/RangelReale/osin/pull/142#discussion_r93583334","pull_request_url":"https://api.github.com/repos/RangelReale/osin/pulls/142","_links":{"self":{"href":"https://api.github.com/repos/RangelReale/osin/pulls/comments/93583334"},"html":{"href":"https://github.com/RangelReale/osin/pull/142#discussion_r93583334"},"pull_request":{"href":"https://api.github.com/repos/RangelReale/osin/pulls/142"}}},"pull_request":{"url":"https://api.github.com/repos/RangelReale/osin/pulls/142","id":98783482,"html_url":"https://github.com/RangelReale/osin/pull/142","diff_url":"https://github.com/RangelReale/osin/pull/142.diff","patch_url":"https://github.com/RangelReale/osin/pull/142.patch","issue_url":"https://api.github.com/repos/RangelReale/osin/issues/142","number":142,"state":"open","locked":false,"title":"add Context support for storage in a backwards compatible manner.","user":{"login":"mwitkow","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow","html_url":"https://github.com/mwitkow","followers_url":"https://api.github.com/users/mwitkow/followers","following_url":"https://api.github.com/users/mwitkow/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow/subscriptions","organizations_url":"https://api.github.com/users/mwitkow/orgs","repos_url":"https://api.github.com/users/mwitkow/repos","events_url":"https://api.github.com/users/mwitkow/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow/received_events","type":"User","site_admin":false},"body":"This fixes https://github.com/RangelReale/osin/issues/139\r\n\r\nBasically this allows `context.Context` of `http.Request` to be propagaded to the Backend. If your server has a deadlien for requests, this means that your storage will obey these requests (e.g. deadlines, cancellation).\r\n\r\nWe currently need it for Go 1.7, since we have a `Storage`  relying on Google Datastore (which uses gRPC and Context cancellation). For Go 1.8 the `database/sql` packages will support cancellable queries: https://tylerchr.blog/golang-18-whats-coming/\r\n\r\n\r\nThis change adds `StorageWithContext` to avoid breaking compatibility with users implementing `Storage`. If a `Storage` is used, a `StorageWithContext` adapter is used.","created_at":"2016-12-20T16:41:45Z","updated_at":"2016-12-22T08:37:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a8475ede0ce0a45a4449d2624b405b4869630c8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/RangelReale/osin/pulls/142/commits","review_comments_url":"https://api.github.com/repos/RangelReale/osin/pulls/142/comments","review_comment_url":"https://api.github.com/repos/RangelReale/osin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RangelReale/osin/issues/142/comments","statuses_url":"https://api.github.com/repos/RangelReale/osin/statuses/de482838e17ca3757aec966d6a1b54440c5ca4f4","head":{"label":"mwitkow:feature/context_support","ref":"feature/context_support","sha":"de482838e17ca3757aec966d6a1b54440c5ca4f4","user":{"login":"mwitkow","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow","html_url":"https://github.com/mwitkow","followers_url":"https://api.github.com/users/mwitkow/followers","following_url":"https://api.github.com/users/mwitkow/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow/subscriptions","organizations_url":"https://api.github.com/users/mwitkow/orgs","repos_url":"https://api.github.com/users/mwitkow/repos","events_url":"https://api.github.com/users/mwitkow/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow/received_events","type":"User","site_admin":false},"repo":{"id":76962270,"name":"osin","full_name":"mwitkow/osin","owner":{"login":"mwitkow","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow","html_url":"https://github.com/mwitkow","followers_url":"https://api.github.com/users/mwitkow/followers","following_url":"https://api.github.com/users/mwitkow/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow/subscriptions","organizations_url":"https://api.github.com/users/mwitkow/orgs","repos_url":"https://api.github.com/users/mwitkow/repos","events_url":"https://api.github.com/users/mwitkow/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mwitkow/osin","description":"Golang OAuth2 server library","fork":true,"url":"https://api.github.com/repos/mwitkow/osin","forks_url":"https://api.github.com/repos/mwitkow/osin/forks","keys_url":"https://api.github.com/repos/mwitkow/osin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mwitkow/osin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mwitkow/osin/teams","hooks_url":"https://api.github.com/repos/mwitkow/osin/hooks","issue_events_url":"https://api.github.com/repos/mwitkow/osin/issues/events{/number}","events_url":"https://api.github.com/repos/mwitkow/osin/events","assignees_url":"https://api.github.com/repos/mwitkow/osin/assignees{/user}","branches_url":"https://api.github.com/repos/mwitkow/osin/branches{/branch}","tags_url":"https://api.github.com/repos/mwitkow/osin/tags","blobs_url":"https://api.github.com/repos/mwitkow/osin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mwitkow/osin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mwitkow/osin/git/refs{/sha}","trees_url":"https://api.github.com/repos/mwitkow/osin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mwitkow/osin/statuses/{sha}","languages_url":"https://api.github.com/repos/mwitkow/osin/languages","stargazers_url":"https://api.github.com/repos/mwitkow/osin/stargazers","contributors_url":"https://api.github.com/repos/mwitkow/osin/contributors","subscribers_url":"https://api.github.com/repos/mwitkow/osin/subscribers","subscription_url":"https://api.github.com/repos/mwitkow/osin/subscription","commits_url":"https://api.github.com/repos/mwitkow/osin/commits{/sha}","git_commits_url":"https://api.github.com/repos/mwitkow/osin/git/commits{/sha}","comments_url":"https://api.github.com/repos/mwitkow/osin/comments{/number}","issue_comment_url":"https://api.github.com/repos/mwitkow/osin/issues/comments{/number}","contents_url":"https://api.github.com/repos/mwitkow/osin/contents/{+path}","compare_url":"https://api.github.com/repos/mwitkow/osin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mwitkow/osin/merges","archive_url":"https://api.github.com/repos/mwitkow/osin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mwitkow/osin/downloads","issues_url":"https://api.github.com/repos/mwitkow/osin/issues{/number}","pulls_url":"https://api.github.com/repos/mwitkow/osin/pulls{/number}","milestones_url":"https://api.github.com/repos/mwitkow/osin/milestones{/number}","notifications_url":"https://api.github.com/repos/mwitkow/osin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mwitkow/osin/labels{/name}","releases_url":"https://api.github.com/repos/mwitkow/osin/releases{/id}","deployments_url":"https://api.github.com/repos/mwitkow/osin/deployments","created_at":"2016-12-20T14:15:48Z","updated_at":"2016-12-20T14:15:50Z","pushed_at":"2016-12-21T11:10:52Z","git_url":"git://github.com/mwitkow/osin.git","ssh_url":"git@github.com:mwitkow/osin.git","clone_url":"https://github.com/mwitkow/osin.git","svn_url":"https://github.com/mwitkow/osin","homepage":null,"size":199,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RangelReale:master","ref":"master","sha":"e09d96c151a3b30cf01c064f06bf50489fb5efcf","user":{"login":"RangelReale","id":369785,"avatar_url":"https://avatars.githubusercontent.com/u/369785?v=3","gravatar_id":"","url":"https://api.github.com/users/RangelReale","html_url":"https://github.com/RangelReale","followers_url":"https://api.github.com/users/RangelReale/followers","following_url":"https://api.github.com/users/RangelReale/following{/other_user}","gists_url":"https://api.github.com/users/RangelReale/gists{/gist_id}","starred_url":"https://api.github.com/users/RangelReale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RangelReale/subscriptions","organizations_url":"https://api.github.com/users/RangelReale/orgs","repos_url":"https://api.github.com/users/RangelReale/repos","events_url":"https://api.github.com/users/RangelReale/events{/privacy}","received_events_url":"https://api.github.com/users/RangelReale/received_events","type":"User","site_admin":false},"repo":{"id":12739005,"name":"osin","full_name":"RangelReale/osin","owner":{"login":"RangelReale","id":369785,"avatar_url":"https://avatars.githubusercontent.com/u/369785?v=3","gravatar_id":"","url":"https://api.github.com/users/RangelReale","html_url":"https://github.com/RangelReale","followers_url":"https://api.github.com/users/RangelReale/followers","following_url":"https://api.github.com/users/RangelReale/following{/other_user}","gists_url":"https://api.github.com/users/RangelReale/gists{/gist_id}","starred_url":"https://api.github.com/users/RangelReale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RangelReale/subscriptions","organizations_url":"https://api.github.com/users/RangelReale/orgs","repos_url":"https://api.github.com/users/RangelReale/repos","events_url":"https://api.github.com/users/RangelReale/events{/privacy}","received_events_url":"https://api.github.com/users/RangelReale/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RangelReale/osin","description":"Golang OAuth2 server library","fork":false,"url":"https://api.github.com/repos/RangelReale/osin","forks_url":"https://api.github.com/repos/RangelReale/osin/forks","keys_url":"https://api.github.com/repos/RangelReale/osin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RangelReale/osin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RangelReale/osin/teams","hooks_url":"https://api.github.com/repos/RangelReale/osin/hooks","issue_events_url":"https://api.github.com/repos/RangelReale/osin/issues/events{/number}","events_url":"https://api.github.com/repos/RangelReale/osin/events","assignees_url":"https://api.github.com/repos/RangelReale/osin/assignees{/user}","branches_url":"https://api.github.com/repos/RangelReale/osin/branches{/branch}","tags_url":"https://api.github.com/repos/RangelReale/osin/tags","blobs_url":"https://api.github.com/repos/RangelReale/osin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RangelReale/osin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RangelReale/osin/git/refs{/sha}","trees_url":"https://api.github.com/repos/RangelReale/osin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RangelReale/osin/statuses/{sha}","languages_url":"https://api.github.com/repos/RangelReale/osin/languages","stargazers_url":"https://api.github.com/repos/RangelReale/osin/stargazers","contributors_url":"https://api.github.com/repos/RangelReale/osin/contributors","subscribers_url":"https://api.github.com/repos/RangelReale/osin/subscribers","subscription_url":"https://api.github.com/repos/RangelReale/osin/subscription","commits_url":"https://api.github.com/repos/RangelReale/osin/commits{/sha}","git_commits_url":"https://api.github.com/repos/RangelReale/osin/git/commits{/sha}","comments_url":"https://api.github.com/repos/RangelReale/osin/comments{/number}","issue_comment_url":"https://api.github.com/repos/RangelReale/osin/issues/comments{/number}","contents_url":"https://api.github.com/repos/RangelReale/osin/contents/{+path}","compare_url":"https://api.github.com/repos/RangelReale/osin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RangelReale/osin/merges","archive_url":"https://api.github.com/repos/RangelReale/osin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RangelReale/osin/downloads","issues_url":"https://api.github.com/repos/RangelReale/osin/issues{/number}","pulls_url":"https://api.github.com/repos/RangelReale/osin/pulls{/number}","milestones_url":"https://api.github.com/repos/RangelReale/osin/milestones{/number}","notifications_url":"https://api.github.com/repos/RangelReale/osin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RangelReale/osin/labels{/name}","releases_url":"https://api.github.com/repos/RangelReale/osin/releases{/id}","deployments_url":"https://api.github.com/repos/RangelReale/osin/deployments","created_at":"2013-09-10T19:52:00Z","updated_at":"2016-12-20T07:18:26Z","pushed_at":"2016-12-21T11:10:53Z","git_url":"git://github.com/RangelReale/osin.git","ssh_url":"git@github.com:RangelReale/osin.git","clone_url":"https://github.com/RangelReale/osin.git","svn_url":"https://github.com/RangelReale/osin","homepage":null,"size":277,"stargazers_count":1017,"watchers_count":1017,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":214,"mirror_url":null,"open_issues_count":26,"forks":214,"open_issues":26,"watchers":1017,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RangelReale/osin/pulls/142"},"html":{"href":"https://github.com/RangelReale/osin/pull/142"},"issue":{"href":"https://api.github.com/repos/RangelReale/osin/issues/142"},"comments":{"href":"https://api.github.com/repos/RangelReale/osin/issues/142/comments"},"review_comments":{"href":"https://api.github.com/repos/RangelReale/osin/pulls/142/comments"},"review_comment":{"href":"https://api.github.com/repos/RangelReale/osin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RangelReale/osin/pulls/142/commits"},"statuses":{"href":"https://api.github.com/repos/RangelReale/osin/statuses/de482838e17ca3757aec966d6a1b54440c5ca4f4"}}}}
{"actor":{"display_login":"mwitkow"}}