{"action":"created","comment":{"url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments/238361216","pull_request_review_id":180883093,"id":238361216,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODM2MTIxNg==","diff_hunk":"@@ -0,0 +1,205 @@\n+package rest\n+\n+import (\n+\t\"bytes\"\n+\t\"encoding/json\"\n+\t\"log\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\tblip \"github.com/couchbase/go-blip\"\n+\tfleecedelta \"github.com/couchbaselabs/go-fleecedelta\"\n+\t\"github.com/google/uuid\"\n+)\n+\n+type BlipTesterClient struct {\n+\tDeltas    bool               // Support deltas on the client side\n+\tRequests  chan *blip.Message // Tests can consume this channel to inspect requests sent to the client\n+\tResponses chan *blip.Message // Tests can consume this channel to inspect responses sent from the client\n+\n+\tbt       *BlipTester\n+\tid       string                       // Generated UUID on creation\n+\tdocsLock sync.RWMutex                 // lock for docs map\n+\tdocs     map[string]map[string][]byte // Map of docID to rev ID to bytes\n+}\n+\n+// NewBlipTesterClient returns a client which emulates the behaviour of a CBL client over BLIP.\n+func NewBlipTesterClient(bt *BlipTester) (client *BlipTesterClient, err error) {\n+\tid, err := uuid.NewRandom()\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tbtc := BlipTesterClient{\n+\t\tid:        id.String(),\n+\t\tbt:        bt,\n+\t\tdocs:      make(map[string]map[string][]byte, 0),\n+\t\tRequests:  make(chan *blip.Message, 1024),\n+\t\tResponses: make(chan *blip.Message, 1024),\n+\t}\n+\n+\tbt.blipContext.HandlerForProfile[messageChanges] = func(request *blip.Message) {\n+\t\tbtc.Requests <- request\n+\t\tlog.Printf(\"client got changes request: %v\", request)\n+\t\tbody, err := request.Body()\n+\t\tif err != nil {\n+\t\t\tpanic(err)\n+\t\t}\n+\n+\t\twantedRevs := []interface{}{}\n+\n+\t\tif string(body) != \"null\" {\n+\t\t\tvar changesReqs [][]interface{}\n+\t\t\terr = json.Unmarshal(body, &changesReqs)\n+\t\t\tif err != nil {\n+\t\t\t\tpanic(err)\n+\t\t\t}\n+\n+\t\t\twantedRevs = make([]interface{}, len(changesReqs))\n+\t\t\t// changesReqs == [[sequence, docID, revID, {deleted}, {size (bytes)}], ...]\n+\t\t\tfor i, changesReq := range changesReqs {\n+\t\t\t\tdocID := changesReq[1].(string)\n+\t\t\t\tbtc.docsLock.RLock()\n+\t\t\t\tif revs, haveDoc := btc.docs[docID]; haveDoc {\n+\t\t\t\t\trevList := make([]string, 0, len(revs))\n+\t\t\t\t\tfor revID := range revs {\n+\t\t\t\t\t\trevList = append(revList, revID)\n+\t\t\t\t\t}\n+\t\t\t\t\twantedRevs[i] = revList // send back all revs we have for SG to determine the ancestor","path":"rest/blip_client_test.go","position":68,"original_position":68,"commit_id":"2657f87ffb894549c1baa23a17ea6ded01259f05","original_commit_id":"2657f87ffb894549c1baa23a17ea6ded01259f05","user":{"login":"adamcfraser","id":8866453,"node_id":"MDQ6VXNlcjg4NjY0NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/8866453?v=4","gravatar_id":"","url":"https://api.github.com/users/adamcfraser","html_url":"https://github.com/adamcfraser","followers_url":"https://api.github.com/users/adamcfraser/followers","following_url":"https://api.github.com/users/adamcfraser/following{/other_user}","gists_url":"https://api.github.com/users/adamcfraser/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcfraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcfraser/subscriptions","organizations_url":"https://api.github.com/users/adamcfraser/orgs","repos_url":"https://api.github.com/users/adamcfraser/repos","events_url":"https://api.github.com/users/adamcfraser/events{/privacy}","received_events_url":"https://api.github.com/users/adamcfraser/received_events","type":"User","site_admin":false},"body":"Stick a TODO: in here to limit the number of wantedRevs (knownRevs) to 20, as I think that's the CBL behaviour.","created_at":"2018-12-03T17:21:43Z","updated_at":"2018-12-03T17:45:52Z","html_url":"https://github.com/couchbase/sync_gateway/pull/3845#discussion_r238361216","pull_request_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments/238361216"},"html":{"href":"https://github.com/couchbase/sync_gateway/pull/3845#discussion_r238361216"},"pull_request":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845"}}},"pull_request":{"url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845","id":235524047,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1NTI0MDQ3","html_url":"https://github.com/couchbase/sync_gateway/pull/3845","diff_url":"https://github.com/couchbase/sync_gateway/pull/3845.diff","patch_url":"https://github.com/couchbase/sync_gateway/pull/3845.patch","issue_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3845","number":3845,"state":"open","locked":false,"title":"#3718 delta sync pull","user":{"login":"bbrks","id":1525809,"node_id":"MDQ6VXNlcjE1MjU4MDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1525809?v=4","gravatar_id":"","url":"https://api.github.com/users/bbrks","html_url":"https://github.com/bbrks","followers_url":"https://api.github.com/users/bbrks/followers","following_url":"https://api.github.com/users/bbrks/following{/other_user}","gists_url":"https://api.github.com/users/bbrks/gists{/gist_id}","starred_url":"https://api.github.com/users/bbrks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbrks/subscriptions","organizations_url":"https://api.github.com/users/bbrks/orgs","repos_url":"https://api.github.com/users/bbrks/repos","events_url":"https://api.github.com/users/bbrks/events{/privacy}","received_events_url":"https://api.github.com/users/bbrks/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-03T17:09:36Z","updated_at":"2018-12-03T17:45:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f467feb1cdad95aa59f1b2b592a2d25f4dc4cb0f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":107354377,"node_id":"MDU6TGFiZWwxMDczNTQzNzc=","url":"https://api.github.com/repos/couchbase/sync_gateway/labels/in%20progress","name":"in progress","color":"ededed","default":false},{"id":109316238,"node_id":"MDU6TGFiZWwxMDkzMTYyMzg=","url":"https://api.github.com/repos/couchbase/sync_gateway/labels/review","name":"review","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845/commits","review_comments_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845/comments","review_comment_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments{/number}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3845/comments","statuses_url":"https://api.github.com/repos/couchbase/sync_gateway/statuses/2657f87ffb894549c1baa23a17ea6ded01259f05","head":{"label":"couchbase:feature/issue_3718_delta_sync_pull","ref":"feature/issue_3718_delta_sync_pull","sha":"2657f87ffb894549c1baa23a17ea6ded01259f05","user":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"repo":{"id":6082996,"node_id":"MDEwOlJlcG9zaXRvcnk2MDgyOTk2","name":"sync_gateway","full_name":"couchbase/sync_gateway","private":false,"owner":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/couchbase/sync_gateway","description":"Manages access and synchronization between Couchbase Lite and Couchbase Server","fork":false,"url":"https://api.github.com/repos/couchbase/sync_gateway","forks_url":"https://api.github.com/repos/couchbase/sync_gateway/forks","keys_url":"https://api.github.com/repos/couchbase/sync_gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/couchbase/sync_gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/couchbase/sync_gateway/teams","hooks_url":"https://api.github.com/repos/couchbase/sync_gateway/hooks","issue_events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/events{/number}","events_url":"https://api.github.com/repos/couchbase/sync_gateway/events","assignees_url":"https://api.github.com/repos/couchbase/sync_gateway/assignees{/user}","branches_url":"https://api.github.com/repos/couchbase/sync_gateway/branches{/branch}","tags_url":"https://api.github.com/repos/couchbase/sync_gateway/tags","blobs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/couchbase/sync_gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/couchbase/sync_gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/couchbase/sync_gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/couchbase/sync_gateway/languages","stargazers_url":"https://api.github.com/repos/couchbase/sync_gateway/stargazers","contributors_url":"https://api.github.com/repos/couchbase/sync_gateway/contributors","subscribers_url":"https://api.github.com/repos/couchbase/sync_gateway/subscribers","subscription_url":"https://api.github.com/repos/couchbase/sync_gateway/subscription","commits_url":"https://api.github.com/repos/couchbase/sync_gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/couchbase/sync_gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/couchbase/sync_gateway/contents/{+path}","compare_url":"https://api.github.com/repos/couchbase/sync_gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/couchbase/sync_gateway/merges","archive_url":"https://api.github.com/repos/couchbase/sync_gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/couchbase/sync_gateway/downloads","issues_url":"https://api.github.com/repos/couchbase/sync_gateway/issues{/number}","pulls_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/couchbase/sync_gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/couchbase/sync_gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/labels{/name}","releases_url":"https://api.github.com/repos/couchbase/sync_gateway/releases{/id}","deployments_url":"https://api.github.com/repos/couchbase/sync_gateway/deployments","created_at":"2012-10-04T22:25:43Z","updated_at":"2018-11-30T18:57:41Z","pushed_at":"2018-12-03T17:10:46Z","git_url":"git://github.com/couchbase/sync_gateway.git","ssh_url":"git@github.com:couchbase/sync_gateway.git","clone_url":"https://github.com/couchbase/sync_gateway.git","svn_url":"https://github.com/couchbase/sync_gateway","homepage":"https://www.couchbase.com/products/sync-gateway","size":30180,"stargazers_count":387,"watchers_count":387,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":125,"mirror_url":null,"archived":false,"open_issues_count":354,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":125,"open_issues":354,"watchers":387,"default_branch":"master"}},"base":{"label":"couchbase:master","ref":"master","sha":"2f162e7244096e4741bb36af007dbbef41904a3a","user":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"repo":{"id":6082996,"node_id":"MDEwOlJlcG9zaXRvcnk2MDgyOTk2","name":"sync_gateway","full_name":"couchbase/sync_gateway","private":false,"owner":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/couchbase/sync_gateway","description":"Manages access and synchronization between Couchbase Lite and Couchbase Server","fork":false,"url":"https://api.github.com/repos/couchbase/sync_gateway","forks_url":"https://api.github.com/repos/couchbase/sync_gateway/forks","keys_url":"https://api.github.com/repos/couchbase/sync_gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/couchbase/sync_gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/couchbase/sync_gateway/teams","hooks_url":"https://api.github.com/repos/couchbase/sync_gateway/hooks","issue_events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/events{/number}","events_url":"https://api.github.com/repos/couchbase/sync_gateway/events","assignees_url":"https://api.github.com/repos/couchbase/sync_gateway/assignees{/user}","branches_url":"https://api.github.com/repos/couchbase/sync_gateway/branches{/branch}","tags_url":"https://api.github.com/repos/couchbase/sync_gateway/tags","blobs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/couchbase/sync_gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/couchbase/sync_gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/couchbase/sync_gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/couchbase/sync_gateway/languages","stargazers_url":"https://api.github.com/repos/couchbase/sync_gateway/stargazers","contributors_url":"https://api.github.com/repos/couchbase/sync_gateway/contributors","subscribers_url":"https://api.github.com/repos/couchbase/sync_gateway/subscribers","subscription_url":"https://api.github.com/repos/couchbase/sync_gateway/subscription","commits_url":"https://api.github.com/repos/couchbase/sync_gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/couchbase/sync_gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/couchbase/sync_gateway/contents/{+path}","compare_url":"https://api.github.com/repos/couchbase/sync_gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/couchbase/sync_gateway/merges","archive_url":"https://api.github.com/repos/couchbase/sync_gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/couchbase/sync_gateway/downloads","issues_url":"https://api.github.com/repos/couchbase/sync_gateway/issues{/number}","pulls_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/couchbase/sync_gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/couchbase/sync_gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/labels{/name}","releases_url":"https://api.github.com/repos/couchbase/sync_gateway/releases{/id}","deployments_url":"https://api.github.com/repos/couchbase/sync_gateway/deployments","created_at":"2012-10-04T22:25:43Z","updated_at":"2018-11-30T18:57:41Z","pushed_at":"2018-12-03T17:10:46Z","git_url":"git://github.com/couchbase/sync_gateway.git","ssh_url":"git@github.com:couchbase/sync_gateway.git","clone_url":"https://github.com/couchbase/sync_gateway.git","svn_url":"https://github.com/couchbase/sync_gateway","homepage":"https://www.couchbase.com/products/sync-gateway","size":30180,"stargazers_count":387,"watchers_count":387,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":125,"mirror_url":null,"archived":false,"open_issues_count":354,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":125,"open_issues":354,"watchers":387,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845"},"html":{"href":"https://github.com/couchbase/sync_gateway/pull/3845"},"issue":{"href":"https://api.github.com/repos/couchbase/sync_gateway/issues/3845"},"comments":{"href":"https://api.github.com/repos/couchbase/sync_gateway/issues/3845/comments"},"review_comments":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845/comments"},"review_comment":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3845/commits"},"statuses":{"href":"https://api.github.com/repos/couchbase/sync_gateway/statuses/2657f87ffb894549c1baa23a17ea6ded01259f05"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"adamcfraser"}}