{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/63763014","id":63763014,"diff_hunk":"@@ -219,19 +182,82 @@ func (s *Service) Points() chan<- *coordinator.WritePointsRequest {\n }\n \n // read points off chan and write them\n-func (s *Service) writePoints() {\n+func (s *Service) run() {\n \tdefer s.wg.Done()\n-\tfor p := range s.points {\n-\t\tfor se, sub := range s.subs {\n-\t\t\tif p.Database == se.db && p.RetentionPolicy == se.rp {\n-\t\t\t\terr := sub.WritePoints(p)\n+\tsubs := make(map[subEntry]PointsWriter)\n+\t// Perform initial update\n+\ts.updateSubs(subs)\n+\tfor {\n+\t\tselect {\n+\t\tcase <-s.update:\n+\t\t\terr := s.updateSubs(subs)\n+\t\t\tif err != nil {\n+\t\t\t\ts.Logger.Println(\"failed to update subscriptions:\", err)\n+\t\t\t}\n+\t\tcase p, ok := <-s.points:\n+\t\t\tif !ok {\n+\t\t\t\treturn\n+\t\t\t}\n+\t\t\tfor se, sub := range subs {\n+\t\t\t\tif p.Database == se.db && p.RetentionPolicy == se.rp {\n+\t\t\t\t\terr := sub.WritePoints(p)","path":"services/subscriber/service.go","position":210,"original_position":210,"commit_id":"96b032f742bbef188f6d66257ea28e672e618817","original_commit_id":"96b032f742bbef188f6d66257ea28e672e618817","user":{"login":"joelegasse","id":1391698,"avatar_url":"https://avatars.githubusercontent.com/u/1391698?v=3","gravatar_id":"","url":"https://api.github.com/users/joelegasse","html_url":"https://github.com/joelegasse","followers_url":"https://api.github.com/users/joelegasse/followers","following_url":"https://api.github.com/users/joelegasse/following{/other_user}","gists_url":"https://api.github.com/users/joelegasse/gists{/gist_id}","starred_url":"https://api.github.com/users/joelegasse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelegasse/subscriptions","organizations_url":"https://api.github.com/users/joelegasse/orgs","repos_url":"https://api.github.com/users/joelegasse/repos","events_url":"https://api.github.com/users/joelegasse/events{/privacy}","received_events_url":"https://api.github.com/users/joelegasse/received_events","type":"User","site_admin":false},"body":"Each HTTP subscription creates a new BatchPoints, then each `Client.Write()` call creates a new `bytes.Buffer` where it then encodes all of the points to line protocol, writing that buffer to the destined remote URL. That buffer is then garbage collected, and the next HTTP subscription will have to redo all of that work.\r\n\r\nIf it's not common to have more than one subscription per DB/RP, then trying to prevent that waste wouldn't do anything.","created_at":"2016-05-18T19:07:23Z","updated_at":"2016-05-18T19:07:23Z","html_url":"https://github.com/influxdata/influxdb/pull/6655#discussion_r63763014","pull_request_url":"https://api.github.com/repos/influxdata/influxdb/pulls/6655","_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/63763014"},"html":{"href":"https://github.com/influxdata/influxdb/pull/6655#discussion_r63763014"},"pull_request":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/6655"}}},"pull_request":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/6655","id":70417315,"html_url":"https://github.com/influxdata/influxdb/pull/6655","diff_url":"https://github.com/influxdata/influxdb/pull/6655.diff","patch_url":"https://github.com/influxdata/influxdb/pull/6655.patch","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/6655","number":6655,"state":"open","locked":false,"title":"Add HTTP(s) Subscriptions","user":{"login":"nathanielc","id":3771906,"avatar_url":"https://avatars.githubusercontent.com/u/3771906?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false},"body":"Adds support for the `http` and `https` protocols for subscriptions.\r\n\r\nTo use it specify a destination like so:\r\n\r\n```\r\nCREATE SUBSCRIPTION name ON db.rp DESTINATIONS ANY 'http://myhost.com:8086'\r\n```\r\n\r\nIf a single HTTP based backed slows down for what ever reason all subscriptions will be effected but normal writes to InfluxDB will continue without issues. Should we isolate each of the destinations?\r\n\r\nA config option has been added to the `[subscription]` section called `http-timeout` which specifies the client timeout when writing data to any http destination. Default is 30s\r\n\r\n- [ ] Rebased/mergable\r\n- [x] Tests pass\r\n- [x] CHANGELOG.md updated\r\n- [x] Sign [CLA](https://influxdata.com/community/cla/) (if not already signed)\r\n","created_at":"2016-05-17T19:39:51Z","updated_at":"2016-05-18T19:07:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"89c93b1700d0470aca5ba1795d4785449714ed47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/influxdata/influxdb/pulls/6655/commits","review_comments_url":"https://api.github.com/repos/influxdata/influxdb/pulls/6655/comments","review_comment_url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/6655/comments","statuses_url":"https://api.github.com/repos/influxdata/influxdb/statuses/96b032f742bbef188f6d66257ea28e672e618817","head":{"label":"influxdata:nc-http-subs","ref":"nc-http-subs","sha":"96b032f742bbef188f6d66257ea28e672e618817","user":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":13124802,"name":"influxdb","full_name":"influxdata/influxdb","owner":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdata/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":false,"url":"https://api.github.com/repos/influxdata/influxdb","forks_url":"https://api.github.com/repos/influxdata/influxdb/forks","keys_url":"https://api.github.com/repos/influxdata/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/influxdb/teams","hooks_url":"https://api.github.com/repos/influxdata/influxdb/hooks","issue_events_url":"https://api.github.com/repos/influxdata/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/influxdb/events","assignees_url":"https://api.github.com/repos/influxdata/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/influxdb/tags","blobs_url":"https://api.github.com/repos/influxdata/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/influxdb/languages","stargazers_url":"https://api.github.com/repos/influxdata/influxdb/stargazers","contributors_url":"https://api.github.com/repos/influxdata/influxdb/contributors","subscribers_url":"https://api.github.com/repos/influxdata/influxdb/subscribers","subscription_url":"https://api.github.com/repos/influxdata/influxdb/subscription","commits_url":"https://api.github.com/repos/influxdata/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/influxdb/merges","archive_url":"https://api.github.com/repos/influxdata/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/influxdb/downloads","issues_url":"https://api.github.com/repos/influxdata/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/influxdb/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/influxdb/deployments","created_at":"2013-09-26T14:31:10Z","updated_at":"2016-05-18T12:50:19Z","pushed_at":"2016-05-18T18:43:58Z","git_url":"git://github.com/influxdata/influxdb.git","ssh_url":"git@github.com:influxdata/influxdb.git","clone_url":"https://github.com/influxdata/influxdb.git","svn_url":"https://github.com/influxdata/influxdb","homepage":"https://influxdata.com","size":60122,"stargazers_count":8085,"watchers_count":8085,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1097,"mirror_url":null,"open_issues_count":423,"forks":1097,"open_issues":423,"watchers":8085,"default_branch":"master"}},"base":{"label":"influxdata:master","ref":"master","sha":"046561181c68189d7a467a87b3550d2990be10aa","user":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":13124802,"name":"influxdb","full_name":"influxdata/influxdb","owner":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdata/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":false,"url":"https://api.github.com/repos/influxdata/influxdb","forks_url":"https://api.github.com/repos/influxdata/influxdb/forks","keys_url":"https://api.github.com/repos/influxdata/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/influxdb/teams","hooks_url":"https://api.github.com/repos/influxdata/influxdb/hooks","issue_events_url":"https://api.github.com/repos/influxdata/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/influxdb/events","assignees_url":"https://api.github.com/repos/influxdata/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/influxdb/tags","blobs_url":"https://api.github.com/repos/influxdata/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/influxdb/languages","stargazers_url":"https://api.github.com/repos/influxdata/influxdb/stargazers","contributors_url":"https://api.github.com/repos/influxdata/influxdb/contributors","subscribers_url":"https://api.github.com/repos/influxdata/influxdb/subscribers","subscription_url":"https://api.github.com/repos/influxdata/influxdb/subscription","commits_url":"https://api.github.com/repos/influxdata/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/influxdb/merges","archive_url":"https://api.github.com/repos/influxdata/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/influxdb/downloads","issues_url":"https://api.github.com/repos/influxdata/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/influxdb/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/influxdb/deployments","created_at":"2013-09-26T14:31:10Z","updated_at":"2016-05-18T12:50:19Z","pushed_at":"2016-05-18T18:43:58Z","git_url":"git://github.com/influxdata/influxdb.git","ssh_url":"git@github.com:influxdata/influxdb.git","clone_url":"https://github.com/influxdata/influxdb.git","svn_url":"https://github.com/influxdata/influxdb","homepage":"https://influxdata.com","size":60122,"stargazers_count":8085,"watchers_count":8085,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1097,"mirror_url":null,"open_issues_count":423,"forks":1097,"open_issues":423,"watchers":8085,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/6655"},"html":{"href":"https://github.com/influxdata/influxdb/pull/6655"},"issue":{"href":"https://api.github.com/repos/influxdata/influxdb/issues/6655"},"comments":{"href":"https://api.github.com/repos/influxdata/influxdb/issues/6655/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/6655/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/6655/commits"},"statuses":{"href":"https://api.github.com/repos/influxdata/influxdb/statuses/96b032f742bbef188f6d66257ea28e672e618817"}}}}