{"action":"created","comment":{"url":"https://api.github.com/repos/juju/charmstore/pulls/comments/93665954","pull_request_review_id":14177527,"id":93665954,"diff_hunk":"@@ -76,22 +76,65 @@ func NewContentChallengeResponse(chal *ContentChallenge, r io.ReadSeeker) (*Cont\n \t}, nil\n }\n \n+// Store stores data blobs in the configured store.\n+type Store struct {\n+\tstore\n+}\n+\n // Store stores data blobs in mongodb, de-duplicating by\n // blob hash.\n-type Store struct {\n+type store interface {\n+\tPut(r io.Reader, name string, size int64, hash string, proof *ContentChallengeResponse) (*ContentChallenge, error)\n+\tPutUnchallenged(r io.Reader, name string, size int64, hash string) error\n+\tOpen(name string) (ReadSeekCloser, int64, error)\n+\tRemove(name string) error\n+}\n+\n+// gridStore stores data blobs in mongodb gridfs, de-duplicating by\n+// blob hash.\n+type gridStore struct {\n \tmstore blobstore.ManagedStorage\n+\tdb     *mgo.Database\n+\tprefix string\n }\n \n // New returns a new blob store that writes to the given database,\n // prefixing its collections with the given prefix.\n+// This is the legacy function. Prefer using NewGridFSFromProviderConfig\n func New(db *mgo.Database, prefix string) *Store {\n \trs := blobstore.NewGridFS(db.Name, prefix, db.Session)\n \treturn &Store{\n-\t\tmstore: blobstore.NewManagedStorage(db, rs),\n+\t\t&gridStore{\n+\t\t\tmstore: blobstore.NewManagedStorage(db, rs),\n+\t\t\tdb:     db,\n+\t\t\tprefix: prefix,\n+\t\t},\n+\t}\n+}\n+\n+// NewBlobstoreFromProviderConfig returns a new blob stor that writes to mongodb\n+// as defined in the given ProviderConfig\n+func NewBlobstoreFromProviderConfig(pc *ProviderConfig) *Store {\n+\tif pc.MongoAddr == \"\" {\n+\t\tlogger.Errorf(\"gridfs config with empty mongo_addr\")\n+\t}\n+\tsession, err := mgo.Dial(pc.MongoAddr)","path":"internal/blobstore/blobstore.go","position":54,"original_position":54,"commit_id":"8cc95888c6417dc5e2f4eabb4c8daaf2a60bfec3","original_commit_id":"8cc95888c6417dc5e2f4eabb4c8daaf2a60bfec3","user":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"body":"ISTM that as we've got things in this PR, we'll be making a network connection to mongodb on every charmstore request. Probably not what we want.","created_at":"2016-12-22T17:37:43Z","updated_at":"2016-12-22T17:42:05Z","html_url":"https://github.com/juju/charmstore/pull/702#discussion_r93665954","pull_request_url":"https://api.github.com/repos/juju/charmstore/pulls/702","_links":{"self":{"href":"https://api.github.com/repos/juju/charmstore/pulls/comments/93665954"},"html":{"href":"https://github.com/juju/charmstore/pull/702#discussion_r93665954"},"pull_request":{"href":"https://api.github.com/repos/juju/charmstore/pulls/702"}}},"pull_request":{"url":"https://api.github.com/repos/juju/charmstore/pulls/702","id":98830017,"html_url":"https://github.com/juju/charmstore/pull/702","diff_url":"https://github.com/juju/charmstore/pull/702.diff","patch_url":"https://github.com/juju/charmstore/pull/702.patch","issue_url":"https://api.github.com/repos/juju/charmstore/issues/702","number":702,"state":"open","locked":false,"title":"add s3 storage for blobs","user":{"login":"jrwren","id":106443,"avatar_url":"https://avatars.githubusercontent.com/u/106443?v=3","gravatar_id":"","url":"https://api.github.com/users/jrwren","html_url":"https://github.com/jrwren","followers_url":"https://api.github.com/users/jrwren/followers","following_url":"https://api.github.com/users/jrwren/following{/other_user}","gists_url":"https://api.github.com/users/jrwren/gists{/gist_id}","starred_url":"https://api.github.com/users/jrwren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrwren/subscriptions","organizations_url":"https://api.github.com/users/jrwren/orgs","repos_url":"https://api.github.com/users/jrwren/repos","events_url":"https://api.github.com/users/jrwren/events{/privacy}","received_events_url":"https://api.github.com/users/jrwren/received_events","type":"User","site_admin":false},"body":"Extract a blobstore \"store\" interface.\r\nImplement provider pattern.\r\nKeep backward compatible blobstore by default.","created_at":"2016-12-20T21:36:14Z","updated_at":"2016-12-22T17:42:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91ca93490400ba5cacb7e15078fda32a8ecaeb22","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/juju/charmstore/pulls/702/commits","review_comments_url":"https://api.github.com/repos/juju/charmstore/pulls/702/comments","review_comment_url":"https://api.github.com/repos/juju/charmstore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juju/charmstore/issues/702/comments","statuses_url":"https://api.github.com/repos/juju/charmstore/statuses/8cc95888c6417dc5e2f4eabb4c8daaf2a60bfec3","head":{"label":"jrwren:011-s3-blobstore","ref":"011-s3-blobstore","sha":"8cc95888c6417dc5e2f4eabb4c8daaf2a60bfec3","user":{"login":"jrwren","id":106443,"avatar_url":"https://avatars.githubusercontent.com/u/106443?v=3","gravatar_id":"","url":"https://api.github.com/users/jrwren","html_url":"https://github.com/jrwren","followers_url":"https://api.github.com/users/jrwren/followers","following_url":"https://api.github.com/users/jrwren/following{/other_user}","gists_url":"https://api.github.com/users/jrwren/gists{/gist_id}","starred_url":"https://api.github.com/users/jrwren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrwren/subscriptions","organizations_url":"https://api.github.com/users/jrwren/orgs","repos_url":"https://api.github.com/users/jrwren/repos","events_url":"https://api.github.com/users/jrwren/events{/privacy}","received_events_url":"https://api.github.com/users/jrwren/received_events","type":"User","site_admin":false},"repo":{"id":22686186,"name":"charmstore","full_name":"jrwren/charmstore","owner":{"login":"jrwren","id":106443,"avatar_url":"https://avatars.githubusercontent.com/u/106443?v=3","gravatar_id":"","url":"https://api.github.com/users/jrwren","html_url":"https://github.com/jrwren","followers_url":"https://api.github.com/users/jrwren/followers","following_url":"https://api.github.com/users/jrwren/following{/other_user}","gists_url":"https://api.github.com/users/jrwren/gists{/gist_id}","starred_url":"https://api.github.com/users/jrwren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrwren/subscriptions","organizations_url":"https://api.github.com/users/jrwren/orgs","repos_url":"https://api.github.com/users/jrwren/repos","events_url":"https://api.github.com/users/jrwren/events{/privacy}","received_events_url":"https://api.github.com/users/jrwren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jrwren/charmstore","description":"The charm store server.","fork":true,"url":"https://api.github.com/repos/jrwren/charmstore","forks_url":"https://api.github.com/repos/jrwren/charmstore/forks","keys_url":"https://api.github.com/repos/jrwren/charmstore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jrwren/charmstore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jrwren/charmstore/teams","hooks_url":"https://api.github.com/repos/jrwren/charmstore/hooks","issue_events_url":"https://api.github.com/repos/jrwren/charmstore/issues/events{/number}","events_url":"https://api.github.com/repos/jrwren/charmstore/events","assignees_url":"https://api.github.com/repos/jrwren/charmstore/assignees{/user}","branches_url":"https://api.github.com/repos/jrwren/charmstore/branches{/branch}","tags_url":"https://api.github.com/repos/jrwren/charmstore/tags","blobs_url":"https://api.github.com/repos/jrwren/charmstore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jrwren/charmstore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jrwren/charmstore/git/refs{/sha}","trees_url":"https://api.github.com/repos/jrwren/charmstore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jrwren/charmstore/statuses/{sha}","languages_url":"https://api.github.com/repos/jrwren/charmstore/languages","stargazers_url":"https://api.github.com/repos/jrwren/charmstore/stargazers","contributors_url":"https://api.github.com/repos/jrwren/charmstore/contributors","subscribers_url":"https://api.github.com/repos/jrwren/charmstore/subscribers","subscription_url":"https://api.github.com/repos/jrwren/charmstore/subscription","commits_url":"https://api.github.com/repos/jrwren/charmstore/commits{/sha}","git_commits_url":"https://api.github.com/repos/jrwren/charmstore/git/commits{/sha}","comments_url":"https://api.github.com/repos/jrwren/charmstore/comments{/number}","issue_comment_url":"https://api.github.com/repos/jrwren/charmstore/issues/comments{/number}","contents_url":"https://api.github.com/repos/jrwren/charmstore/contents/{+path}","compare_url":"https://api.github.com/repos/jrwren/charmstore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jrwren/charmstore/merges","archive_url":"https://api.github.com/repos/jrwren/charmstore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jrwren/charmstore/downloads","issues_url":"https://api.github.com/repos/jrwren/charmstore/issues{/number}","pulls_url":"https://api.github.com/repos/jrwren/charmstore/pulls{/number}","milestones_url":"https://api.github.com/repos/jrwren/charmstore/milestones{/number}","notifications_url":"https://api.github.com/repos/jrwren/charmstore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jrwren/charmstore/labels{/name}","releases_url":"https://api.github.com/repos/jrwren/charmstore/releases{/id}","deployments_url":"https://api.github.com/repos/jrwren/charmstore/deployments","created_at":"2014-08-06T14:45:49Z","updated_at":"2015-09-15T14:47:29Z","pushed_at":"2016-12-20T21:35:51Z","git_url":"git://github.com/jrwren/charmstore.git","ssh_url":"git@github.com:jrwren/charmstore.git","clone_url":"https://github.com/jrwren/charmstore.git","svn_url":"https://github.com/jrwren/charmstore","homepage":null,"size":5057,"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":"juju:v5-unstable","ref":"v5-unstable","sha":"01ec4f38180caf144cc3d3512cd0426cd72e16e9","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":20720417,"name":"charmstore","full_name":"juju/charmstore","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/charmstore","description":"The charm store server.","fork":false,"url":"https://api.github.com/repos/juju/charmstore","forks_url":"https://api.github.com/repos/juju/charmstore/forks","keys_url":"https://api.github.com/repos/juju/charmstore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/charmstore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/charmstore/teams","hooks_url":"https://api.github.com/repos/juju/charmstore/hooks","issue_events_url":"https://api.github.com/repos/juju/charmstore/issues/events{/number}","events_url":"https://api.github.com/repos/juju/charmstore/events","assignees_url":"https://api.github.com/repos/juju/charmstore/assignees{/user}","branches_url":"https://api.github.com/repos/juju/charmstore/branches{/branch}","tags_url":"https://api.github.com/repos/juju/charmstore/tags","blobs_url":"https://api.github.com/repos/juju/charmstore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/charmstore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/charmstore/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/charmstore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/charmstore/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/charmstore/languages","stargazers_url":"https://api.github.com/repos/juju/charmstore/stargazers","contributors_url":"https://api.github.com/repos/juju/charmstore/contributors","subscribers_url":"https://api.github.com/repos/juju/charmstore/subscribers","subscription_url":"https://api.github.com/repos/juju/charmstore/subscription","commits_url":"https://api.github.com/repos/juju/charmstore/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/charmstore/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/charmstore/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/charmstore/issues/comments{/number}","contents_url":"https://api.github.com/repos/juju/charmstore/contents/{+path}","compare_url":"https://api.github.com/repos/juju/charmstore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/charmstore/merges","archive_url":"https://api.github.com/repos/juju/charmstore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/charmstore/downloads","issues_url":"https://api.github.com/repos/juju/charmstore/issues{/number}","pulls_url":"https://api.github.com/repos/juju/charmstore/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/charmstore/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/charmstore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/charmstore/labels{/name}","releases_url":"https://api.github.com/repos/juju/charmstore/releases{/id}","deployments_url":"https://api.github.com/repos/juju/charmstore/deployments","created_at":"2014-06-11T09:53:37Z","updated_at":"2016-12-03T15:02:16Z","pushed_at":"2016-12-20T21:36:15Z","git_url":"git://github.com/juju/charmstore.git","ssh_url":"git@github.com:juju/charmstore.git","clone_url":"https://github.com/juju/charmstore.git","svn_url":"https://github.com/juju/charmstore","homepage":null,"size":6807,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":46,"forks":23,"open_issues":46,"watchers":10,"default_branch":"v5-unstable"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/charmstore/pulls/702"},"html":{"href":"https://github.com/juju/charmstore/pull/702"},"issue":{"href":"https://api.github.com/repos/juju/charmstore/issues/702"},"comments":{"href":"https://api.github.com/repos/juju/charmstore/issues/702/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/charmstore/pulls/702/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/charmstore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juju/charmstore/pulls/702/commits"},"statuses":{"href":"https://api.github.com/repos/juju/charmstore/statuses/8cc95888c6417dc5e2f4eabb4c8daaf2a60bfec3"}}}}
{"actor":{"display_login":"rogpeppe"}}