{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/78736904","id":78736904,"diff_hunk":"@@ -0,0 +1,123 @@\n+package client\n+\n+import (\n+\t\"bytes\"\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"net\"\n+\t\"time\"\n+)\n+\n+var ErrLargePoint = errors.New(\"point exceeds allowed size\")\n+\n+const (\n+\t// UDPPayloadSize is a reasonable default payload size for UDP packets that\n+\t// could be travelling over the internet.\n+\tUDPPayloadSize = 512\n+\n+\t// MaxPayloadSize is a safe maximum limit for a UDP payload over IPv4\n+\tMaxUDPPayloadSize = 65467\n+)\n+\n+// UDPConfig is the config data needed to create a UDP Client\n+type UDPConfig struct {\n+\t// Addr should be of the form \"host:port\"\n+\t// or \"[ipv6-host%zone]:port\".\n+\tAddr string\n+\n+\t// PayloadSize is the maximum size of a UDP client message, optional\n+\t// Tune this based on your network. Defaults to UDPBufferSize.\n+\tPayloadSize int\n+}\n+\n+// NewUDPClient returns a client interface for writing to an InfluxDB UDP\n+// service from the given config.\n+func NewUDPClient(conf UDPConfig) (Client, error) {\n+\tvar udpAddr *net.UDPAddr\n+\tudpAddr, err := net.ResolveUDPAddr(\"udp\", conf.Addr)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tconn, err := net.DialUDP(\"udp\", nil, udpAddr)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tpayloadSize := conf.PayloadSize\n+\tif payloadSize == 0 {\n+\t\tpayloadSize = UDPPayloadSize\n+\t}\n+\n+\treturn &udpclient{\n+\t\tconn:        conn,\n+\t\tpayloadSize: payloadSize,\n+\t}, nil\n+}\n+\n+// Ping will check to see if the server is up with an optional timeout on waiting for leader.\n+// Ping returns how long the request took, the version of the server it connected to, and an error if one occurred.\n+func (uc *udpclient) Ping(timeout time.Duration) (time.Duration, string, error) {\n+\treturn 0, \"\", nil\n+}\n+\n+// Close releases the udpclient's resources.\n+func (uc *udpclient) Close() error {\n+\treturn uc.conn.Close()\n+}\n+\n+type udpclient struct {\n+\tconn        io.WriteCloser\n+\tpayloadSize int\n+}\n+\n+func (uc *udpclient) Write(bp BatchPoints) error {\n+\tvar b bytes.Buffer\n+\tvar d time.Duration\n+\td, _ = time.ParseDuration(\"1\" + bp.Precision())\n+\n+\tvar delayedError error\n+\n+\tvar checkBuffer = func(s string) {\n+\t\tif b.Len() > 0 && b.Len()+len(s) > uc.payloadSize {\n+\t\t\tif _, err := uc.conn.Write(b.Bytes()); err != nil {\n+\t\t\t\tdelayedError = err\n+\t\t\t}\n+\t\t\tb.Reset()\n+\t\t}\n+\t}\n+\n+\tfor _, p := range bp.Points() {\n+\t\tpoint := p.pt.RoundedString(d) + \"\\n\"\n+\t\tif len(point) > MaxUDPPayloadSize {\n+\t\t\tdelayedError = ErrLargePoint\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tcheckBuffer(point)\n+\n+\t\tif p.Time().IsZero() || len(point) <= uc.payloadSize {\n+\t\t\tb.WriteString(point)\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tpoints := p.pt.Split(uc.payloadSize - 1) // newline will be added\n+\t\tfor _, sp := range points {\n+\t\t\tpoint = sp.RoundedString(d) + \"\\n\"\n+\t\t\tcheckBuffer(point)\n+\t\t\tb.WriteString(point)\n+\t\t}\n+\t}\n+\n+\tif b.Len() > 0 {\n+\t\tif _, err := uc.conn.Write(b.Bytes()); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t}","path":"client/v2/udp.go","position":117,"original_position":117,"commit_id":"8a28850eceae4915ca899f0c2892a0cf9e78ebd6","original_commit_id":"8a28850eceae4915ca899f0c2892a0cf9e78ebd6","user":{"login":"phemmer","id":1826947,"avatar_url":"https://avatars.githubusercontent.com/u/1826947?v=3","gravatar_id":"","url":"https://api.github.com/users/phemmer","html_url":"https://github.com/phemmer","followers_url":"https://api.github.com/users/phemmer/followers","following_url":"https://api.github.com/users/phemmer/following{/other_user}","gists_url":"https://api.github.com/users/phemmer/gists{/gist_id}","starred_url":"https://api.github.com/users/phemmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phemmer/subscriptions","organizations_url":"https://api.github.com/users/phemmer/orgs","repos_url":"https://api.github.com/users/phemmer/repos","events_url":"https://api.github.com/users/phemmer/events{/privacy}","received_events_url":"https://api.github.com/users/phemmer/received_events","type":"User","site_admin":false},"body":"If we just wrote the buffer, shouldn't there be a `b.Reset()` here?","created_at":"2016-09-14T12:20:37Z","updated_at":"2016-09-14T12:20:37Z","html_url":"https://github.com/influxdata/influxdb/pull/7305#discussion_r78736904","pull_request_url":"https://api.github.com/repos/influxdata/influxdb/pulls/7305","_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/78736904"},"html":{"href":"https://github.com/influxdata/influxdb/pull/7305#discussion_r78736904"},"pull_request":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/7305"}}},"pull_request":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/7305","id":85152912,"html_url":"https://github.com/influxdata/influxdb/pull/7305","diff_url":"https://github.com/influxdata/influxdb/pull/7305.diff","patch_url":"https://github.com/influxdata/influxdb/pull/7305.patch","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/7305","number":7305,"state":"open","locked":false,"title":"UDP Client: Split large points","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":"The v2 UDP client will attempt to split points that exceed the configured payload size. It will only do this for points that have a timestamp specified.\r\n\r\nThis follows from several ancestors: #6913 #7288 \r\n\r\n###### Required for all non-trivial PRs\r\n- [ ] Rebased/mergable\r\n- [ ] Tests pass\r\n- [ ] CHANGELOG.md updated\r\n\r\n###### Required only if applicable\r\n_You can erase any checkboxes below this note if they are not applicable to your Pull Request._\r\n- [ ] [InfluxQL Spec](https://github.com/influxdata/influxdb/blob/master/influxql/README.md) updated\r\n- [ ] Provide example syntax\r\n- [ ] Update man page when modifying a command\r\n","created_at":"2016-09-14T01:23:59Z","updated_at":"2016-09-14T12:20:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4bdef526ebac4099863ca08c79d9d91f8a032ac2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/influxdata/influxdb/pulls/7305/commits","review_comments_url":"https://api.github.com/repos/influxdata/influxdb/pulls/7305/comments","review_comment_url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/7305/comments","statuses_url":"https://api.github.com/repos/influxdata/influxdb/statuses/8a28850eceae4915ca899f0c2892a0cf9e78ebd6","head":{"label":"influxdata:jl-udp-split","ref":"jl-udp-split","sha":"8a28850eceae4915ca899f0c2892a0cf9e78ebd6","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-09-14T12:19:22Z","pushed_at":"2016-09-14T07:20:52Z","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":61504,"stargazers_count":8869,"watchers_count":8869,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1240,"mirror_url":null,"open_issues_count":425,"forks":1240,"open_issues":425,"watchers":8869,"default_branch":"master"}},"base":{"label":"influxdata:master","ref":"master","sha":"a0dfd8ae5efd22b1d6b72da03cbc8aa98119b769","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-09-14T12:19:22Z","pushed_at":"2016-09-14T07:20:52Z","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":61504,"stargazers_count":8869,"watchers_count":8869,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1240,"mirror_url":null,"open_issues_count":425,"forks":1240,"open_issues":425,"watchers":8869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/7305"},"html":{"href":"https://github.com/influxdata/influxdb/pull/7305"},"issue":{"href":"https://api.github.com/repos/influxdata/influxdb/issues/7305"},"comments":{"href":"https://api.github.com/repos/influxdata/influxdb/issues/7305/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/7305/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/7305/commits"},"statuses":{"href":"https://api.github.com/repos/influxdata/influxdb/statuses/8a28850eceae4915ca899f0c2892a0cf9e78ebd6"}}}}
{"actor":{"display_login":"phemmer"}}