Cloud events 0.1#53
Conversation
|
|
||
| package event | ||
|
|
||
| // BUG(inlined): must add header encoding/decoding |
There was a problem hiding this comment.
Nit: can we make this into a more traditional: TODO(inlined)?
| return nil, err | ||
| } | ||
| func isJSONEncoding(encoding string) bool { | ||
| return encoding == contentTypeJSON || encoding == "text/json" |
There was a problem hiding this comment.
Above there's binary json too so curious if this catches them all or if that's the intention?
There was a problem hiding this comment.
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)
|
|
||
| package event | ||
|
|
||
| // BUG(inlined): must add header encoding/decoding |
There was a problem hiding this comment.
Nit: can we make this into a more traditional: TODO(inlined)?
| return nil, err | ||
| } | ||
|
|
||
| if err := assertRequiredFields(context); err != nil { |
There was a problem hiding this comment.
nit, assert to me implies 'assert' action as in things fail noisily. consider renaming this to verifyRequiredFields.
| if h.dataType.Kind() == reflect.Ptr { | ||
| elemType = h.dataType.Elem() | ||
| } | ||
| dataPtrVal := reflect.New(elemType) |
There was a problem hiding this comment.
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.
|
|
||
| // Mux allows developers to handle logically related groups of | ||
| // functionality multiplexed based on the event type. | ||
| // BUG: Mux relies on JSON encoding for events. |
There was a problem hiding this comment.
instead of BUG, consider TODO?
inlined
left a comment
There was a problem hiding this comment.
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.
| return nil, err | ||
| } | ||
| func isJSONEncoding(encoding string) bool { | ||
| return encoding == contentTypeJSON || encoding == "text/json" |
There was a problem hiding this comment.
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)
|
|
||
| package event | ||
|
|
||
| // BUG(inlined): must add header encoding/decoding |
| return nil, err | ||
| } | ||
|
|
||
| if err := assertRequiredFields(context); err != nil { |
| @@ -0,0 +1,16 @@ | |||
| load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | |||
There was a problem hiding this comment.
No need for bazel build files anymore, now use 'ko'.
| ctx.CloudEventsVersion = "0.1" | ||
| ctx.EventTime = time.Now().UTC() | ||
|
|
||
| if ctx.EventID == "" { |
There was a problem hiding this comment.
Maybe just use this package instead:
https://github.com/google/uuid
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/elafros/eventing/pkg/event" |
There was a problem hiding this comment.
Looks like this file might not have been updated yet? should be github.com/knative/eventing/pkg/event?
|
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 |
|
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 |
|
CLAs look good, thanks! |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
vaikas
left a comment
There was a problem hiding this comment.
mainly just some nits, but please change the copyright to match the other files.
| @@ -0,0 +1,99 @@ | |||
| /* | |||
| Copyright 2018 Google LLC | |||
There was a problem hiding this comment.
Can you change this to match the other headers (Knative authors...)
| */ | ||
|
|
||
| // 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 |
There was a problem hiding this comment.
Not sure what the comment about bazel is. Regardless we don't use bazel anymore.
| ) | ||
|
|
||
| func init() { | ||
| flag.StringVar(&context.EventID, "event-id", "", "Event ID to use. Defaults to a UUID") |
There was a problem hiding this comment.
Nit: Defaults to a generated UUID.
In case somebody takes it as a specific string UUID :)
| h.Set(name, value) | ||
| } | ||
| } | ||
| func getReqHeader(h http.Header, name string, value *string) error { |
There was a problem hiding this comment.
nit, I would prefer getRequiredHeader so it's not confused with something like getRequestHeader.
| return &e.Context, nil | ||
| } | ||
|
|
||
| // NewRequest craetes an HTTP request for Structured content encoding. |
| } | ||
| } | ||
|
|
||
| // Verifies the that a function has the right number of in and out params and that they are |
|
|
||
| // 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 |
There was a problem hiding this comment.
I don't think @param does anything here? Perhaps:
- fn a function of type func(...
There was a problem hiding this comment.
Done; will change again in the next iteration to add more signatures.
| // (error) | ||
| func assertOutParamSignature(fnType reflect.Type) { | ||
| if fnType.NumOut() != 1 { | ||
| panic(usage + "; wrong output count") |
There was a problem hiding this comment.
Can you print here something like:
; wrong output count. Expected 1 got %d", fnType.NumOut()
| return fnType.In(0) | ||
| } | ||
|
|
||
| // Alocates a new instance of type t and returns: |
|
/retest |
|
@inlined: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
/lgtm |
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)
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
* 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
Fixes Issue #47
Proposed Changes
Implements the 0.1 ratified version of CloudEvents' transport on HTTP.
Known bugs: