From 50957a53ecb418609165fc750345ecc2f2f52245 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Fri, 30 Aug 2019 11:26:59 -0700 Subject: [PATCH 1/5] Fix up JSON type mappings Signed-off-by: Evan Anderson --- json-format.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/json-format.md b/json-format.md index 3cedfc1c8..9395c92c5 100644 --- a/json-format.md +++ b/json-format.md @@ -63,13 +63,13 @@ with exceptions noted below. | CloudEvents | JSON | | ------------- | -------------------------------------------------------------- | -| String | [string][json-string] | +| Boolean | [boolean][json-bool] | Integer | [number][json-number], only the `int` component is permitted | +| String | [string][json-string] | | Binary | [string][json-string], [Base64-encoded][base64] binary | +| URI | [string][json-string] following [RFC 3986][rfc3986] | | URI-reference | [string][json-string] following [RFC 3986][rfc3986] | | Timestamp | [string][json-string] following [RFC 3339][rfc3339] (ISO 8601) | -| Map | [JSON object][json-object] | -| Any | [JSON value][json-value] | Extension specifications MAY define diverging mapping rules for the values of attributes they define. @@ -314,6 +314,7 @@ also valid in a request): https://www.iana.org/assignments/media-types/application/geo+json-seq [json-object]: https://tools.ietf.org/html/rfc7159#section-4 [json-seq]: https://www.iana.org/assignments/media-types/application/json-seq +[json-bool]: https://tools.ietf.org/html/rfc7159#section-3 [json-number]: https://tools.ietf.org/html/rfc7159#section-6 [json-string]: https://tools.ietf.org/html/rfc7159#section-7 [json-value]: https://tools.ietf.org/html/rfc7159#section-3 From 0693deda2a896d084f64d4877d9ba9b3ed826b11 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Fri, 30 Aug 2019 14:49:45 -0700 Subject: [PATCH 2/5] Fix type mapping for AMQP Signed-off-by: Evan Anderson --- amqp-format.md | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/amqp-format.md b/amqp-format.md index c3b6be131..03739d0fc 100644 --- a/amqp-format.md +++ b/amqp-format.md @@ -55,13 +55,13 @@ exceptions noted below. | CloudEvents | AMQP | | ------------- | --------------------------- | -| String | [string][amqp-string] | +| Boolean | [boolean][amqp-boolean] | | Integer | [long][amqp-long] | +| String | [string][amqp-string] | | Binary | [binary][amqp-binary] | | URI | [string][amqp-string] | | URI-reference | [string][amqp-string] | | Timestamp | [timestamp][amqp-timestamp] | -| Any | See 2.3. | A CloudEvents AMQP format implementation MUST allow for attribute values to be convertible from/to their canonical CloudEvents string representation. For @@ -88,13 +88,6 @@ any revision of such a specification, MUST also define explicit mapping rules for all other event formats that are part of the CloudEvents core at the time of the submission or revision. -### 2.3. Mapping Any-typed Attributes - -`Any`-typed CloudEvents values can either hold a `String`, or a `Binary` value, -or a `Map`. `Map` entry values are also `Any` typed. AMQP's type system natively -represents dynamic typing in its [type system encoding][type-system-encoding], -and therefore immediately allows for the required variant type representation. - ## 3. References - [RFC2046][rfc2046] Multipurpose Internet Mail Extensions (MIME) Part Two: @@ -109,18 +102,16 @@ and therefore immediately allows for the required variant type representation. https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html [type-system-encoding]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#section-encodings -[amqp-string]: +[amqp-boolean]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-string [amqp-long]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-long +[amqp-string]: + http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-string [amqp-binary]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-binary [amqp-timestamp]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-timestamp -[amqp-map]: - http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-map -[amqp-describedtype]: - http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#doc-idp38080 [rfc2046]: https://tools.ietf.org/html/rfc2046 [rfc2119]: https://tools.ietf.org/html/rfc2119 [rfc4627]: https://tools.ietf.org/html/rfc4627 From 93ca9885f62dad14b06b12718aaf31b3f7686ae8 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Fri, 30 Aug 2019 15:13:21 -0700 Subject: [PATCH 3/5] Add `data` to AMQP. Signed-off-by: Evan Anderson --- amqp-format.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/amqp-format.md b/amqp-format.md index 03739d0fc..63e8a5930 100644 --- a/amqp-format.md +++ b/amqp-format.md @@ -13,7 +13,8 @@ This document is a working draft. 1. [Introduction](#1-introduction) 2. [Attributes](#2-attributes) -3. [References](#3-references) +3. [Data](#3-data) +4. [References](#4-references) ## 1. Introduction @@ -88,7 +89,12 @@ any revision of such a specification, MUST also define explicit mapping rules for all other event formats that are part of the CloudEvents core at the time of the submission or revision. -## 3. References +## 3. Data + +The CloudEvents `data` payload SHALL be mapped to a single [AMQP +data][amqp-data] section. + +## 4. References - [RFC2046][rfc2046] Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types @@ -112,9 +118,12 @@ the submission or revision. http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-binary [amqp-timestamp]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-timestamp +[amqp-data]: + http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-data [rfc2046]: https://tools.ietf.org/html/rfc2046 [rfc2119]: https://tools.ietf.org/html/rfc2119 [rfc4627]: https://tools.ietf.org/html/rfc4627 [rfc4648]: https://tools.ietf.org/html/rfc4648 [rfc6839]: https://tools.ietf.org/html/rfc6839#section-3.1 [rfc8259]: https://tools.ietf.org/html/rfc8259 +[oasis-amqp-1.0]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html From dda685793af9ff534b4d2b8546a09db0612d384e Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Fri, 30 Aug 2019 15:32:14 -0700 Subject: [PATCH 4/5] Add payload data to amqp-format.md Signed-off-by: Evan Anderson --- amqp-format.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/amqp-format.md b/amqp-format.md index 63e8a5930..f2ae0e0ad 100644 --- a/amqp-format.md +++ b/amqp-format.md @@ -2,8 +2,8 @@ ## Abstract -The AMQP Format for CloudEvents defines how event attributes are expressed in -the [AMQP 1.0 Type System][type-system]. +The AMQP Format for CloudEvents defines how event attributes and payload data +are expressed in the [AMQP 1.0 Type System][type-system]. ## Status of this document @@ -126,4 +126,5 @@ data][amqp-data] section. [rfc4648]: https://tools.ietf.org/html/rfc4648 [rfc6839]: https://tools.ietf.org/html/rfc6839#section-3.1 [rfc8259]: https://tools.ietf.org/html/rfc8259 -[oasis-amqp-1.0]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html +[oasis-amqp-1.0]: + http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html From 50b574512ddcac4d544d45a7fd511628c631d604 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Tue, 10 Sep 2019 15:01:01 -0700 Subject: [PATCH 5/5] Update AMQP data encoding per discussion in #492 Signed-off-by: Evan Anderson --- amqp-format.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/amqp-format.md b/amqp-format.md index f2ae0e0ad..4f2a21eb5 100644 --- a/amqp-format.md +++ b/amqp-format.md @@ -91,8 +91,17 @@ the submission or revision. ## 3. Data -The CloudEvents `data` payload SHALL be mapped to a single [AMQP -data][amqp-data] section. +Before encoding, the AMQP serializer MUST first determine the runtime data type +of the data content. This may be determined by examining the data for characters +outside the UTF-8 range or by consulting the `datacontenttype` attribute. + +If the implementation determines that the type of the data is binary, the value +MUST be stored in the payload as a single [AMQP data][amqp-data] section. + +For other types (non-binary data without a `datacontenttype` attribute), the +implementation MUST translate the data value into an [AMQP type +system][type-system] value and the value MUST be stored in an [AMQP +value][amqp-value] section. ## 4. References @@ -109,7 +118,7 @@ data][amqp-data] section. [type-system-encoding]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#section-encodings [amqp-boolean]: - http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-string + http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-boolean [amqp-long]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-long [amqp-string]: @@ -120,6 +129,8 @@ data][amqp-data] section. http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-timestamp [amqp-data]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-data +[amqp-value]: + http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-value [rfc2046]: https://tools.ietf.org/html/rfc2046 [rfc2119]: https://tools.ietf.org/html/rfc2119 [rfc4627]: https://tools.ietf.org/html/rfc4627