Skip to content

Cloud events 0.1#53

Merged
google-prow-robot merged 3 commits into
knative:masterfrom
inlined:cloud-events-0.1
Jul 12, 2018
Merged

Cloud events 0.1#53
google-prow-robot merged 3 commits into
knative:masterfrom
inlined:cloud-events-0.1

Conversation

@inlined
Copy link
Copy Markdown
Contributor

@inlined inlined commented Apr 26, 2018

Fixes Issue #47

Proposed Changes

Implements the 0.1 ratified version of CloudEvents' transport on HTTP.

Known bugs:

  • Non-ASCII characters for context properties in binary encoding is not yet supported
  • Extension property names are case-lossy in binary encoding (spec bug; raised with CloudEvents group)

@google-prow-robot google-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 26, 2018
Comment thread pkg/event/encoding_binary.go Outdated

package event

// BUG(inlined): must add header encoding/decoding
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we make this into a more traditional: TODO(inlined)?

Comment thread pkg/event/event.go
return nil, err
}
func isJSONEncoding(encoding string) bool {
return encoding == contentTypeJSON || encoding == "text/json"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above there's binary json too so curious if this catches them all or if that's the intention?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment. The spec is a bit annoying that the envelope and the data are orthogonally encoded. This is meant to just check the valid data encodings regardless of the outer encoding (structured JSON, binary JSON, some new unknown format, etc)

Comment thread pkg/event/encoding_binary.go Outdated

package event

// BUG(inlined): must add header encoding/decoding
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we make this into a more traditional: TODO(inlined)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread pkg/event/encoding_structured.go Outdated
return nil, err
}

if err := assertRequiredFields(context); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, assert to me implies 'assert' action as in things fail noisily. consider renaming this to verifyRequiredFields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread pkg/event/handler.go Outdated
if h.dataType.Kind() == reflect.Ptr {
elemType = h.dataType.Elem()
}
dataPtrVal := reflect.New(elemType)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of reflection going on here, I think it would be nice to have some comments on what's going on there.

Comment thread pkg/event/handler.go Outdated

// Mux allows developers to handle logically related groups of
// functionality multiplexed based on the event type.
// BUG: Mux relies on JSON encoding for events.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of BUG, consider TODO?

Copy link
Copy Markdown
Contributor Author

@inlined inlined left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased against master since we're choosing to abandon changes this was diffed against.

Going to work on a follow up that makes this expose @evankanderson's proposed API signature. I'd also like to eventually be smarter about the encoding (e.g. can the mime package help?) and ideally also support Google's dialect so we can promote this to its own repo & use it within GCF and Knative.

Comment thread pkg/event/event.go
return nil, err
}
func isJSONEncoding(encoding string) bool {
return encoding == contentTypeJSON || encoding == "text/json"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment. The spec is a bit annoying that the envelope and the data are orthogonally encoded. This is meant to just check the valid data encodings regardless of the outer encoding (structured JSON, binary JSON, some new unknown format, etc)

Comment thread pkg/event/encoding_binary.go Outdated

package event

// BUG(inlined): must add header encoding/decoding
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread pkg/event/encoding_structured.go Outdated
return nil, err
}

if err := assertRequiredFields(context); err != nil {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread cmd/sendevent/BUILD.bazel Outdated
@@ -0,0 +1,16 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for bazel build files anymore, now use 'ko'.

Comment thread cmd/sendevent/main.go
ctx.CloudEventsVersion = "0.1"
ctx.EventTime = time.Now().UTC()

if ctx.EventID == "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just use this package instead:
https://github.com/google/uuid

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread pkg/event/event_test.go Outdated
"testing"
"time"

"github.com/elafros/eventing/pkg/event"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this file might not have been updated yet? should be github.com/knative/eventing/pkg/event?

@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@inlined
Copy link
Copy Markdown
Contributor Author

inlined commented Jul 11, 2018

The diff is too large; I'm going to create a new local branch, cherry pick affected files, and force push a single commit with the relevant diffs

@inlined inlined changed the base branch from v0.1 to master July 11, 2018 17:00
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@google-prow-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inlined

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown
Contributor

@vaikas vaikas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainly just some nits, but please change the copyright to match the other files.

Comment thread cmd/sendevent/main.go Outdated
@@ -0,0 +1,99 @@
/*
Copyright 2018 Google LLC
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to match the other headers (Knative authors...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread cmd/sendevent/main.go Outdated
*/

// Implements a simple utility for sending a JSON-encoded sample event.
// Not wired to bazel because this utility is meant to be run directly rather
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the comment about bazel is. Regardless we don't use bazel anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment thread cmd/sendevent/main.go Outdated
)

func init() {
flag.StringVar(&context.EventID, "event-id", "", "Event ID to use. Defaults to a UUID")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Defaults to a generated UUID.
In case somebody takes it as a specific string UUID :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread pkg/event/encoding_binary.go Outdated
h.Set(name, value)
}
}
func getReqHeader(h http.Header, name string, value *string) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, I would prefer getRequiredHeader so it's not confused with something like getRequestHeader.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread pkg/event/encoding_structured.go Outdated
return &e.Context, nil
}

// NewRequest craetes an HTTP request for Structured content encoding.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: creates

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread pkg/event/handler.go Outdated
}
}

// Verifies the that a function has the right number of in and out params and that they are
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/the that/that/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread pkg/event/handler.go Outdated

// Handler creates an EventHandler that implements http.Handler
// Will panic in case of a type error
// @param fn a function of type func(<your data struct>, *event.Context) error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think @param does anything here? Perhaps:

  • fn a function of type func(...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done; will change again in the next iteration to add more signatures.

Comment thread pkg/event/handler.go Outdated
// (error)
func assertOutParamSignature(fnType reflect.Type) {
if fnType.NumOut() != 1 {
panic(usage + "; wrong output count")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you print here something like:
; wrong output count. Expected 1 got %d", fnType.NumOut()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread pkg/event/handler.go
return fnType.In(0)
}

// Alocates a new instance of type t and returns:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocates

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@inlined
Copy link
Copy Markdown
Contributor Author

inlined commented Jul 12, 2018

/retest
It seems like I got a spurious permission error?

@google-prow-robot
Copy link
Copy Markdown

google-prow-robot commented Jul 12, 2018

@inlined: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-knative-eventing-go-coverage 9ac9c1a link /test pull-knative-eventing-go-coverage

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 12, 2018

/lgtm

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 12, 2018
@google-prow-robot google-prow-robot merged commit d64bbec into knative:master Jul 12, 2018
dprotaso added a commit to dprotaso/eventing that referenced this pull request Sep 12, 2018
Includes the following changes
1e7c2e7 Update static_watcher.go
d688349 Include note about embedding the ManualWatcher in the InformedWatcher
767d6a5 Few changes to the configmap package
0122abd The test logger will now log the correct caller (knative#63)
e7a4b0d Dont call flag.parse in pkg/test (knative#62)
b213523 Update test-infra dependency (knative#61)
382a2bf Make kube_checks generic so that it can be used in serving (knative#58)
760afb6 cleanup (knative#57)
eedc0a9 Make verify-codegen.sh compatible with OS X (knative#54)
6eff182 Remove docker repo from e2e flags (knative#53)
4be5c07 Vendor the test-infra scripts (knative#52)
8c687df Update WaitForEndpointState to return response (knative#51)
8f6a3be Update knative/pkg/test (knative#50)
3ca4270 Add a logkey for the reconcile key. (knative#49)
62d2560 Add Istio DestinationRule and Policy into Istio apis and clients (knative#43)
f4a77d7 Add a common test clients file (knative#46)
450739d Add common test logging module (knative#45)
dprotaso added a commit to dprotaso/eventing that referenced this pull request Sep 12, 2018
Includes the following changes:
8fc80de Few changes to the configmap package (knative#59)
0122abd The test logger will now log the correct caller (knative#63)
e7a4b0d Dont call flag.parse in pkg/test (knative#62)
b213523 Update test-infra dependency (knative#61)
382a2bf Make kube_checks generic so that it can be used in serving (knative#58)
760afb6 cleanup (knative#57)
eedc0a9 Make verify-codegen.sh compatible with OS X (knative#54)
6eff182 Remove docker repo from e2e flags (knative#53)
4be5c07 Vendor the test-infra scripts (knative#52)
8c687df Update WaitForEndpointState to return response (knative#51)
8f6a3be Update knative/pkg/test (knative#50)
3ca4270 Add a logkey for the reconcile key. (knative#49)
62d2560 Add Istio DestinationRule and Policy into Istio apis and clients (knative#43)
f4a77d7 Add a common test clients file (knative#46)
450739d Add common test logging module (knative#45
knative-prow-robot pushed a commit that referenced this pull request Sep 17, 2018
* bump knative/pkg to 8fc80de

Includes the following changes:
8fc80de Few changes to the configmap package (#59)
0122abd The test logger will now log the correct caller (#63)
e7a4b0d Dont call flag.parse in pkg/test (#62)
b213523 Update test-infra dependency (#61)
382a2bf Make kube_checks generic so that it can be used in serving (#58)
760afb6 cleanup (#57)
eedc0a9 Make verify-codegen.sh compatible with OS X (#54)
6eff182 Remove docker repo from e2e flags (#53)
4be5c07 Vendor the test-infra scripts (#52)
8c687df Update WaitForEndpointState to return response (#51)
8f6a3be Update knative/pkg/test (#50)
3ca4270 Add a logkey for the reconcile key. (#49)
62d2560 Add Istio DestinationRule and Policy into Istio apis and clients (#43)
f4a77d7 Add a common test clients file (#46)
450739d Add common test logging module (#45

* Use updated methods that indicate that the configmap.Watcher is using an informer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants