{"action":"created","comment":{"url":"https://api.github.com/repos/fnproject/fn/pulls/comments/183134571","pull_request_review_id":114081663,"id":183134571,"diff_hunk":"@@ -0,0 +1,183 @@\n+package protocol\n+\n+import (\n+\t\"bytes\"\n+\t\"context\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"net/http\"\n+\t\"reflect\"\n+\t\"time\"\n+\n+\t\"go.opencensus.io/trace\"\n+\n+\t\"github.com/fnproject/fn/api/models\"\n+)\n+\n+// CloudEvent is the official JSON representation of a CloudEvent: https://github.com/cloudevents/spec/blob/master/serialization.md\n+type CloudEvent struct {\n+\tCloudEventsVersion string                 `json:\"cloudEventsVersion\"`\n+\tEventID            string                 `json:\"eventID\"`\n+\tSource             string                 `json:\"source\"`\n+\tEventType          string                 `json:\"eventType\"`\n+\tEventTypeVersion   string                 `json:\"eventTypeVersion\"`\n+\tEventTime          time.Time              `json:\"eventTime\"` // TODO: ensure rfc3339 format\n+\tSchemaURL          string                 `json:\"schemaURL\"`\n+\tContentType        string                 `json:\"contentType\"`\n+\tExtensions         map[string]interface{} `json:\"extensions\"`\n+\tData               interface{}            `json:\"data\"` // from docs: the payload is encoded into a media format which is specified by the contentType attribute (e.g. application/json)\n+}\n+\n+type cloudEventIn struct {\n+\tCloudEvent\n+\n+\t// Deadline string `json:\"deadline\"`\n+\t// Protocol CallRequestHTTP `json:\"protocol\"`\n+}\n+\n+// cloudEventOut the expected response from the function container\n+type cloudEventOut struct {\n+\tCloudEvent\n+\n+\t// Protocol    *CallResponseHTTP `json:\"protocol,omitempty\"`\n+}\n+\n+// CloudEventProtocol converts stdin/stdout streams from HTTP into JSON format.\n+type CloudEventProtocol struct {\n+\t// These are the container input streams, not the input from the request or the output for the response\n+\tin  io.Writer\n+\tout io.Reader\n+}\n+\n+func (p *CloudEventProtocol) IsStreamable() bool {\n+\treturn true\n+}\n+\n+func (h *CloudEventProtocol) writeJSONToContainer(ci CallInfo) error {\n+\tbuf := bufPool.Get().(*bytes.Buffer)\n+\tbuf.Reset()\n+\tdefer bufPool.Put(buf)\n+\n+\t_, err := io.Copy(buf, ci.Input())\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tin := cloudEventIn{\n+\t\tCloudEvent: CloudEvent{\n+\t\t\tContentType: ci.ContentType(),\n+\t\t\tEventID:     ci.CallID(),\n+\t\t\tExtensions: map[string]interface{}{","path":"api/agent/protocol/cloudevent.go","position":null,"original_position":71,"commit_id":"5b38804936072d2a59680a494cb37f62017ccda7","original_commit_id":"a853d212b249936cadd03ae6a0ad72ded53645ea","user":{"login":"treeder","id":75826,"avatar_url":"https://avatars3.githubusercontent.com/u/75826?v=4","gravatar_id":"","url":"https://api.github.com/users/treeder","html_url":"https://github.com/treeder","followers_url":"https://api.github.com/users/treeder/followers","following_url":"https://api.github.com/users/treeder/following{/other_user}","gists_url":"https://api.github.com/users/treeder/gists{/gist_id}","starred_url":"https://api.github.com/users/treeder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treeder/subscriptions","organizations_url":"https://api.github.com/users/treeder/orgs","repos_url":"https://api.github.com/users/treeder/repos","events_url":"https://api.github.com/users/treeder/events{/privacy}","received_events_url":"https://api.github.com/users/treeder/received_events","type":"User","site_admin":false},"body":"Would make sense. Maybe it's something left up to the users. ","created_at":"2018-04-20T18:28:35Z","updated_at":"2018-04-20T18:28:35Z","html_url":"https://github.com/fnproject/fn/pull/948#discussion_r183134571","pull_request_url":"https://api.github.com/repos/fnproject/fn/pulls/948","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/fnproject/fn/pulls/comments/183134571"},"html":{"href":"https://github.com/fnproject/fn/pull/948#discussion_r183134571"},"pull_request":{"href":"https://api.github.com/repos/fnproject/fn/pulls/948"}},"in_reply_to_id":182688364},"pull_request":{"url":"https://api.github.com/repos/fnproject/fn/pulls/948","id":182694004,"html_url":"https://github.com/fnproject/fn/pull/948","diff_url":"https://github.com/fnproject/fn/pull/948.diff","patch_url":"https://github.com/fnproject/fn/pull/948.patch","issue_url":"https://api.github.com/repos/fnproject/fn/issues/948","number":948,"state":"open","locked":false,"title":"CloudEvents I/O format support.","user":{"login":"treeder","id":75826,"avatar_url":"https://avatars3.githubusercontent.com/u/75826?v=4","gravatar_id":"","url":"https://api.github.com/users/treeder","html_url":"https://github.com/treeder","followers_url":"https://api.github.com/users/treeder/followers","following_url":"https://api.github.com/users/treeder/following{/other_user}","gists_url":"https://api.github.com/users/treeder/gists{/gist_id}","starred_url":"https://api.github.com/users/treeder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treeder/subscriptions","organizations_url":"https://api.github.com/users/treeder/orgs","repos_url":"https://api.github.com/users/treeder/repos","events_url":"https://api.github.com/users/treeder/events{/privacy}","received_events_url":"https://api.github.com/users/treeder/received_events","type":"User","site_admin":false},"body":"This adds CloudEvent format as I/O format. \r\n\r\nThis now has support for ingestion of CloudEvents as input via HTTP as well as the function I/O format. \r\n","created_at":"2018-04-19T07:57:18Z","updated_at":"2018-04-20T18:28:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"026aca5293a349f850ab112c0355ae839c658c0a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"skinowski","id":6537562,"avatar_url":"https://avatars2.githubusercontent.com/u/6537562?v=4","gravatar_id":"","url":"https://api.github.com/users/skinowski","html_url":"https://github.com/skinowski","followers_url":"https://api.github.com/users/skinowski/followers","following_url":"https://api.github.com/users/skinowski/following{/other_user}","gists_url":"https://api.github.com/users/skinowski/gists{/gist_id}","starred_url":"https://api.github.com/users/skinowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skinowski/subscriptions","organizations_url":"https://api.github.com/users/skinowski/orgs","repos_url":"https://api.github.com/users/skinowski/repos","events_url":"https://api.github.com/users/skinowski/events{/privacy}","received_events_url":"https://api.github.com/users/skinowski/received_events","type":"User","site_admin":false},{"login":"rikgibson","id":16211574,"avatar_url":"https://avatars3.githubusercontent.com/u/16211574?v=4","gravatar_id":"","url":"https://api.github.com/users/rikgibson","html_url":"https://github.com/rikgibson","followers_url":"https://api.github.com/users/rikgibson/followers","following_url":"https://api.github.com/users/rikgibson/following{/other_user}","gists_url":"https://api.github.com/users/rikgibson/gists{/gist_id}","starred_url":"https://api.github.com/users/rikgibson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rikgibson/subscriptions","organizations_url":"https://api.github.com/users/rikgibson/orgs","repos_url":"https://api.github.com/users/rikgibson/repos","events_url":"https://api.github.com/users/rikgibson/events{/privacy}","received_events_url":"https://api.github.com/users/rikgibson/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/fnproject/fn/pulls/948/commits","review_comments_url":"https://api.github.com/repos/fnproject/fn/pulls/948/comments","review_comment_url":"https://api.github.com/repos/fnproject/fn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fnproject/fn/issues/948/comments","statuses_url":"https://api.github.com/repos/fnproject/fn/statuses/5b38804936072d2a59680a494cb37f62017ccda7","head":{"label":"fnproject:cloudevents","ref":"cloudevents","sha":"5b38804936072d2a59680a494cb37f62017ccda7","user":{"login":"fnproject","id":30273834,"avatar_url":"https://avatars2.githubusercontent.com/u/30273834?v=4","gravatar_id":"","url":"https://api.github.com/users/fnproject","html_url":"https://github.com/fnproject","followers_url":"https://api.github.com/users/fnproject/followers","following_url":"https://api.github.com/users/fnproject/following{/other_user}","gists_url":"https://api.github.com/users/fnproject/gists{/gist_id}","starred_url":"https://api.github.com/users/fnproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fnproject/subscriptions","organizations_url":"https://api.github.com/users/fnproject/orgs","repos_url":"https://api.github.com/users/fnproject/repos","events_url":"https://api.github.com/users/fnproject/events{/privacy}","received_events_url":"https://api.github.com/users/fnproject/received_events","type":"Organization","site_admin":false},"repo":{"id":97652025,"name":"fn","full_name":"fnproject/fn","owner":{"login":"fnproject","id":30273834,"avatar_url":"https://avatars2.githubusercontent.com/u/30273834?v=4","gravatar_id":"","url":"https://api.github.com/users/fnproject","html_url":"https://github.com/fnproject","followers_url":"https://api.github.com/users/fnproject/followers","following_url":"https://api.github.com/users/fnproject/following{/other_user}","gists_url":"https://api.github.com/users/fnproject/gists{/gist_id}","starred_url":"https://api.github.com/users/fnproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fnproject/subscriptions","organizations_url":"https://api.github.com/users/fnproject/orgs","repos_url":"https://api.github.com/users/fnproject/repos","events_url":"https://api.github.com/users/fnproject/events{/privacy}","received_events_url":"https://api.github.com/users/fnproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fnproject/fn","description":"The container native, cloud agnostic serverless platform.","fork":false,"url":"https://api.github.com/repos/fnproject/fn","forks_url":"https://api.github.com/repos/fnproject/fn/forks","keys_url":"https://api.github.com/repos/fnproject/fn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fnproject/fn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fnproject/fn/teams","hooks_url":"https://api.github.com/repos/fnproject/fn/hooks","issue_events_url":"https://api.github.com/repos/fnproject/fn/issues/events{/number}","events_url":"https://api.github.com/repos/fnproject/fn/events","assignees_url":"https://api.github.com/repos/fnproject/fn/assignees{/user}","branches_url":"https://api.github.com/repos/fnproject/fn/branches{/branch}","tags_url":"https://api.github.com/repos/fnproject/fn/tags","blobs_url":"https://api.github.com/repos/fnproject/fn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fnproject/fn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fnproject/fn/git/refs{/sha}","trees_url":"https://api.github.com/repos/fnproject/fn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fnproject/fn/statuses/{sha}","languages_url":"https://api.github.com/repos/fnproject/fn/languages","stargazers_url":"https://api.github.com/repos/fnproject/fn/stargazers","contributors_url":"https://api.github.com/repos/fnproject/fn/contributors","subscribers_url":"https://api.github.com/repos/fnproject/fn/subscribers","subscription_url":"https://api.github.com/repos/fnproject/fn/subscription","commits_url":"https://api.github.com/repos/fnproject/fn/commits{/sha}","git_commits_url":"https://api.github.com/repos/fnproject/fn/git/commits{/sha}","comments_url":"https://api.github.com/repos/fnproject/fn/comments{/number}","issue_comment_url":"https://api.github.com/repos/fnproject/fn/issues/comments{/number}","contents_url":"https://api.github.com/repos/fnproject/fn/contents/{+path}","compare_url":"https://api.github.com/repos/fnproject/fn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fnproject/fn/merges","archive_url":"https://api.github.com/repos/fnproject/fn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fnproject/fn/downloads","issues_url":"https://api.github.com/repos/fnproject/fn/issues{/number}","pulls_url":"https://api.github.com/repos/fnproject/fn/pulls{/number}","milestones_url":"https://api.github.com/repos/fnproject/fn/milestones{/number}","notifications_url":"https://api.github.com/repos/fnproject/fn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fnproject/fn/labels{/name}","releases_url":"https://api.github.com/repos/fnproject/fn/releases{/id}","deployments_url":"https://api.github.com/repos/fnproject/fn/deployments","created_at":"2017-07-18T23:22:46Z","updated_at":"2018-04-20T16:40:04Z","pushed_at":"2018-04-20T16:40:08Z","git_url":"git://github.com/fnproject/fn.git","ssh_url":"git@github.com:fnproject/fn.git","clone_url":"https://github.com/fnproject/fn.git","svn_url":"https://github.com/fnproject/fn","homepage":"http://fnproject.io","size":152235,"stargazers_count":2656,"watchers_count":2656,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":185,"mirror_url":null,"archived":false,"open_issues_count":107,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":185,"open_issues":107,"watchers":2656,"default_branch":"master"}},"base":{"label":"fnproject:master","ref":"master","sha":"07388774db7a97dc9b4c9fbce294b1de854a522e","user":{"login":"fnproject","id":30273834,"avatar_url":"https://avatars2.githubusercontent.com/u/30273834?v=4","gravatar_id":"","url":"https://api.github.com/users/fnproject","html_url":"https://github.com/fnproject","followers_url":"https://api.github.com/users/fnproject/followers","following_url":"https://api.github.com/users/fnproject/following{/other_user}","gists_url":"https://api.github.com/users/fnproject/gists{/gist_id}","starred_url":"https://api.github.com/users/fnproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fnproject/subscriptions","organizations_url":"https://api.github.com/users/fnproject/orgs","repos_url":"https://api.github.com/users/fnproject/repos","events_url":"https://api.github.com/users/fnproject/events{/privacy}","received_events_url":"https://api.github.com/users/fnproject/received_events","type":"Organization","site_admin":false},"repo":{"id":97652025,"name":"fn","full_name":"fnproject/fn","owner":{"login":"fnproject","id":30273834,"avatar_url":"https://avatars2.githubusercontent.com/u/30273834?v=4","gravatar_id":"","url":"https://api.github.com/users/fnproject","html_url":"https://github.com/fnproject","followers_url":"https://api.github.com/users/fnproject/followers","following_url":"https://api.github.com/users/fnproject/following{/other_user}","gists_url":"https://api.github.com/users/fnproject/gists{/gist_id}","starred_url":"https://api.github.com/users/fnproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fnproject/subscriptions","organizations_url":"https://api.github.com/users/fnproject/orgs","repos_url":"https://api.github.com/users/fnproject/repos","events_url":"https://api.github.com/users/fnproject/events{/privacy}","received_events_url":"https://api.github.com/users/fnproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fnproject/fn","description":"The container native, cloud agnostic serverless platform.","fork":false,"url":"https://api.github.com/repos/fnproject/fn","forks_url":"https://api.github.com/repos/fnproject/fn/forks","keys_url":"https://api.github.com/repos/fnproject/fn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fnproject/fn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fnproject/fn/teams","hooks_url":"https://api.github.com/repos/fnproject/fn/hooks","issue_events_url":"https://api.github.com/repos/fnproject/fn/issues/events{/number}","events_url":"https://api.github.com/repos/fnproject/fn/events","assignees_url":"https://api.github.com/repos/fnproject/fn/assignees{/user}","branches_url":"https://api.github.com/repos/fnproject/fn/branches{/branch}","tags_url":"https://api.github.com/repos/fnproject/fn/tags","blobs_url":"https://api.github.com/repos/fnproject/fn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fnproject/fn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fnproject/fn/git/refs{/sha}","trees_url":"https://api.github.com/repos/fnproject/fn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fnproject/fn/statuses/{sha}","languages_url":"https://api.github.com/repos/fnproject/fn/languages","stargazers_url":"https://api.github.com/repos/fnproject/fn/stargazers","contributors_url":"https://api.github.com/repos/fnproject/fn/contributors","subscribers_url":"https://api.github.com/repos/fnproject/fn/subscribers","subscription_url":"https://api.github.com/repos/fnproject/fn/subscription","commits_url":"https://api.github.com/repos/fnproject/fn/commits{/sha}","git_commits_url":"https://api.github.com/repos/fnproject/fn/git/commits{/sha}","comments_url":"https://api.github.com/repos/fnproject/fn/comments{/number}","issue_comment_url":"https://api.github.com/repos/fnproject/fn/issues/comments{/number}","contents_url":"https://api.github.com/repos/fnproject/fn/contents/{+path}","compare_url":"https://api.github.com/repos/fnproject/fn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fnproject/fn/merges","archive_url":"https://api.github.com/repos/fnproject/fn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fnproject/fn/downloads","issues_url":"https://api.github.com/repos/fnproject/fn/issues{/number}","pulls_url":"https://api.github.com/repos/fnproject/fn/pulls{/number}","milestones_url":"https://api.github.com/repos/fnproject/fn/milestones{/number}","notifications_url":"https://api.github.com/repos/fnproject/fn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fnproject/fn/labels{/name}","releases_url":"https://api.github.com/repos/fnproject/fn/releases{/id}","deployments_url":"https://api.github.com/repos/fnproject/fn/deployments","created_at":"2017-07-18T23:22:46Z","updated_at":"2018-04-20T16:40:04Z","pushed_at":"2018-04-20T16:40:08Z","git_url":"git://github.com/fnproject/fn.git","ssh_url":"git@github.com:fnproject/fn.git","clone_url":"https://github.com/fnproject/fn.git","svn_url":"https://github.com/fnproject/fn","homepage":"http://fnproject.io","size":152235,"stargazers_count":2656,"watchers_count":2656,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":185,"mirror_url":null,"archived":false,"open_issues_count":107,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":185,"open_issues":107,"watchers":2656,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fnproject/fn/pulls/948"},"html":{"href":"https://github.com/fnproject/fn/pull/948"},"issue":{"href":"https://api.github.com/repos/fnproject/fn/issues/948"},"comments":{"href":"https://api.github.com/repos/fnproject/fn/issues/948/comments"},"review_comments":{"href":"https://api.github.com/repos/fnproject/fn/pulls/948/comments"},"review_comment":{"href":"https://api.github.com/repos/fnproject/fn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fnproject/fn/pulls/948/commits"},"statuses":{"href":"https://api.github.com/repos/fnproject/fn/statuses/5b38804936072d2a59680a494cb37f62017ccda7"}},"author_association":"OWNER"}}
{"actor":{"display_login":"treeder"}}