{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/63755409","id":63755409,"diff_hunk":"@@ -38,53 +40,50 @@ type subEntry struct {\n // to defined third party destinations.\n // Subscriptions are defined per database and retention policy.\n type Service struct {\n-\tsubs       map[subEntry]PointsWriter\n \tMetaClient interface {\n \t\tDatabases() []meta.DatabaseInfo\n \t\tWaitForDataChanged() chan struct{}\n \t}\n \tNewPointsWriter func(u url.URL) (PointsWriter, error)\n \tLogger          *log.Logger\n+\tupdate          chan struct{}\n \tstatMap         *expvar.Map\n \tpoints          chan *coordinator.WritePointsRequest\n \twg              sync.WaitGroup\n \tclosed          bool\n \tclosing         chan struct{}\n \tmu              sync.Mutex\n+\tconf            Config\n }\n \n // NewService returns a subscriber service with given settings\n func NewService(c Config) *Service {\n-\treturn &Service{\n-\t\tsubs:            make(map[subEntry]PointsWriter),\n-\t\tNewPointsWriter: newPointsWriter,\n-\t\tLogger:          log.New(os.Stderr, \"[subscriber] \", log.LstdFlags),\n-\t\tstatMap:         influxdb.NewStatistics(\"subscriber\", \"subscriber\", nil),\n-\t\tpoints:          make(chan *coordinator.WritePointsRequest),\n-\t\tclosed:          true,\n-\t\tclosing:         make(chan struct{}),\n+\ts := &Service{\n+\t\tLogger:  log.New(os.Stderr, \"[subscriber] \", log.LstdFlags),\n+\t\tstatMap: influxdb.NewStatistics(\"subscriber\", \"subscriber\", nil),\n+\t\tpoints:  make(chan *coordinator.WritePointsRequest, 100),\n+\t\tclosed:  true,\n+\t\tconf:    c,\n \t}\n+\ts.NewPointsWriter = s.newPointsWriter\n+\treturn s\n }\n \n // Open starts the subscription service.\n func (s *Service) Open() error {\n \ts.mu.Lock()\n \tdefer s.mu.Unlock()\n-\n-\ts.closing = make(chan struct{})\n-\n \tif s.MetaClient == nil {\n-\t\tpanic(\"no meta store\")\n+\t\treturn errors.New(\"no meta store\")\n \t}\n \n \ts.closed = false\n \n-\t// Perform initial update\n-\ts.Update()\n+\ts.closing = make(chan struct{})\n+\ts.update = make(chan struct{})\n \n-\ts.wg.Add(1)\n-\tgo s.writePoints()\n-\t// Do not wait for this goroutine since it block until a meta change occurs.\n+\ts.wg.Add(2)\n+\tgo s.run()","path":"services/subscriber/service.go","position":81,"original_position":81,"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":"It's just a personal preference, but I like to see the `Done()` in close proximity to the `Add()` for `WaitGroup`s. Rather than seeing them separated by pages of code in different functions.\r\n\r\nWhat do you think about `go func() { defer wg.Done(); s.run() }()` instead of embedding the `wg.Done()` in each of the called functions?","created_at":"2016-05-18T18:22:56Z","updated_at":"2016-05-18T18:22:56Z","html_url":"https://github.com/influxdata/influxdb/pull/6655#discussion_r63755409","pull_request_url":"https://api.github.com/repos/influxdata/influxdb/pulls/6655","_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/63755409"},"html":{"href":"https://github.com/influxdata/influxdb/pull/6655#discussion_r63755409"},"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-18T18:22:56Z","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-18T17:37:44Z","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-18T17:37:44Z","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"}}}}