-
Notifications
You must be signed in to change notification settings - Fork 630
Upgrading to CloudEvents 1.0 #2157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,7 +171,7 @@ func (r *Handler) serveHTTP(ctx context.Context, event cloudevents.Event, resp * | |
| } | ||
|
|
||
| // Remove the TTL attribute that is used by the Broker. | ||
| originalV3 := event.Context.AsV03() | ||
| originalV1 := event.Context.AsV1() | ||
| ttl, ttlKey := broker.GetTTL(event.Context) | ||
| if ttl == nil { | ||
| // Only messages sent by the Broker should be here. If the attribute isn't here, then the | ||
|
|
@@ -182,8 +182,8 @@ func (r *Handler) serveHTTP(ctx context.Context, event cloudevents.Event, resp * | |
| // framework returns a 500 to the caller, so the Channel would send this repeatedly. | ||
| return nil | ||
| } | ||
| delete(originalV3.Extensions, ttlKey) | ||
| event.Context = originalV3 | ||
| delete(originalV1.Extensions, ttlKey) | ||
| event.Context = originalV1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there are reason why we bump all events to V1? Can't broker/trigger be just pass through? |
||
|
|
||
| r.logger.Debug("Received message", zap.Any("triggerRef", triggerRef)) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,26 +23,26 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| // V03TTLAttribute is the name of the CloudEvents 0.3 extension attribute used to store the | ||
| // V1TTLAttribute is the name of the CloudEvents 1.0 extension attribute used to store the | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert this file too. This has been now fixed correctly. refer to #2244 |
||
| // Broker's TTL (number of times a single event can reply through a Broker continuously). All | ||
| // interactions with the attribute should be done through the GetTTL and SetTTL functions. | ||
| V03TTLAttribute = "knativebrokerttl" | ||
| V1TTLAttribute = "knativebrokerttl" | ||
| ) | ||
|
|
||
| // GetTTL finds the TTL in the EventContext using a case insensitive comparison | ||
| // for the key. The second return param, is the case preserved key that matched. | ||
| // Depending on the encoding/transport, the extension case could be changed. | ||
| func GetTTL(ctx cloudevents.EventContext) (interface{}, string) { | ||
| for k, v := range ctx.AsV03().Extensions { | ||
| if lower := strings.ToLower(k); lower == V03TTLAttribute { | ||
| for k, v := range ctx.AsV1().Extensions { | ||
| if lower := strings.ToLower(k); lower == V1TTLAttribute { | ||
| return v, k | ||
| } | ||
| } | ||
| return nil, V03TTLAttribute | ||
| return nil, V1TTLAttribute | ||
| } | ||
|
|
||
| // SetTTL sets the TTL into the EventContext. ttl should be a positive integer. | ||
| func SetTTL(ctx cloudevents.EventContext, ttl interface{}) (cloudevents.EventContext, error) { | ||
| err := ctx.SetExtension(V03TTLAttribute, ttl) | ||
| err := ctx.SetExtension(V1TTLAttribute, ttl) | ||
| return ctx, err | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this file as this has been now fixed correctly.
/hold