Skip to content

Commit 4af4b73

Browse files
authored
Initial attempt at batch clarification (cloudevents#1154)
* Initial attempt at batch clarification. This treats batch-mode as a full-on third content mode (as it really is). It attempts to clarify support in each transport and event format, as well as removing duplication (e.g. in JSON format) of what batch mode is about, and the odd "JSON batch format is a separate event format" aspect. Some parts may have been missed, and I'm thoroughly expecting some push back :) Signed-off-by: Jon Skeet <[email protected]> * Address review feedback (This includes removing some italics around content modes - we should probably do more of that, to be honest.) Signed-off-by: Jon Skeet <[email protected]> --------- Signed-off-by: Jon Skeet <[email protected]>
1 parent e9c982a commit 4af4b73

12 files changed

+53
-39
lines changed

cloudevents/SDK.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,18 @@ based on the parameters set, most importantly the CloudEvents spec version.
109109

110110
#### Encode/Decode an Event
111111

112-
Each SDK will support encoding and decoding an Event with regards to a transport
113-
and encoding. `Structured` encoding is the easiest to support, as it is just
114-
`json`, but `Binary` is fairly custom for each transport.
112+
Each SDK MUST support encoding and decoding an Event with regards to a transport
113+
and encoding:
114+
115+
- Each SDK MUST support structured-mode messages for each transport that it
116+
supports.
117+
- Each SDK SHOULD support binary-mode messages for each transport that it
118+
supports.
119+
- Each SDK SHOULD support batch-mode messages for each transport that it
120+
supports (where the event format and transport combination supports batch mode).
121+
- Each SDK SHOULD indicate which modes it supports for each supported event
122+
format, both in the [table below](#feature-support) and in any SDK-specific
123+
documentation provided.
115124

116125
#### Data
117126

cloudevents/bindings/amqp-protocol-binding.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ format][message-format].
5555

5656
### 1.3. Content Modes
5757

58-
The specification defines two content modes for transferring events:
59-
_structured_ and _binary_. Every compliant implementation SHOULD support both
60-
modes.
58+
The CloudEvents specification defines three content modes for transferring
59+
events: _structured_, _binary_ and _batch_. The AMQP protocol binding does not
60+
currently support the batch content mode. Every compliant implementation SHOULD
61+
support both structured and binary modes.
6162

6263
In the _structured_ content mode, event metadata attributes and event data are
6364
placed into the AMQP message's [application data][data] section using an

cloudevents/bindings/http-protocol-binding.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ which is compatible with HTTP 1.1 semantics.
6161

6262
### 1.3. Content Modes
6363

64-
This specification defines three content modes for transferring events:
65-
_binary_, _structured_ and _batched_. Every compliant implementation SHOULD
66-
support the _structured_ and _binary_ modes.
64+
The CloudEvents specification defines three content modes for transferring
65+
events: _structured_, _binary_ and _batch_. The HTTP protocol binding supports
66+
all three content modes. Every compliant implementation SHOULD
67+
support both structured and binary modes.
6768

6869
In the _binary_ content mode, the value of the event `data` is placed into the
6970
HTTP request, or response, body as-is, with the `datacontenttype` attribute
@@ -401,14 +402,12 @@ Content-Length: nnnn
401402

402403
In the _batched_ content mode several events are batched into a single HTTP
403404
request or response body. The chosen [event format](#14-event-formats) MUST
404-
define how a batch is represented. Based on the [JSON format][json-format] (that
405-
MUST be supported by any compliant implementation), the [JSON Batch
406-
format][json-batch-format] is an event format that supports batching.
405+
define how a batch is represented, including a suitable media type.
407406

408407
#### 3.3.1. HTTP Content-Type
409408

410409
The [HTTP `Content-Type`][content-type] header MUST be set to the media type of
411-
an [event format](#14-event-formats).
410+
the batch mode for the [event format](#14-event-formats).
412411

413412
Example for the [JSON Batch format][json-batch-format]:
414413

cloudevents/bindings/kafka-protocol-binding.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ the records.
7070

7171
### 1.3. Content Modes
7272

73-
The specification defines two content modes for transferring events:
74-
_structured_ and _binary_.
73+
The CloudEvents specification defines three content modes for transferring
74+
events: _structured_, _binary_ and _batch_. The Kafka protocol binding does not
75+
currently support the batch content mode. Every compliant implementation SHOULD
76+
support both structured and binary modes.
77+
78+
The specification defines three content modes for transferring events:
79+
_structured_, _binary_ and _batch_. The Kafka protocol binding does not
80+
currently support the _batch_ content mode.
7581

7682
In the _structured_ content mode, event metadata attributes and event data are
7783
placed into the Kafka message value section using an

cloudevents/bindings/mqtt-protocol-binding.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ MQTT PUBLISH messages ([3.1.1][3-publish], [5.0][5-publish]).
4949

5050
### 1.3. Content Modes
5151

52-
The specification defines two content modes for transferring events:
53-
_structured_ and _binary_.
52+
The CloudEvents specification defines three content modes for transferring
53+
events: _structured_, _binary_ and _batch_. The MQTT protocol binding does not
54+
currently support the batch content mode. Every compliant implementation SHOULD
55+
support both structured and binary modes.
5456

5557
The _binary_ mode _only_ applies to MQTT 5.0, because of MQTT 3.1.1's lack of
5658
support for custom metadata.

cloudevents/bindings/nats-protocol-binding.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ the NATS protocol as client messages that are [produced][nats-pub-proto] and
5050

5151
### 1.3 Content Modes
5252

53-
This specification defines two content modes for transferring events: _binary_
54-
and _structured_.
53+
The CloudEvents specification defines three content modes for transferring
54+
events: _structured_, _binary_ and _batch_. The NATS protocol binding does not
55+
currently support the batch content mode. Every compliant implementation SHOULD
56+
support both structured and binary modes.
5557

5658
In the _binary_ content mode, event metadata attributes are placed in message
5759
headers and the event data are placed in the NATS message payload. Binary mode

cloudevents/bindings/websockets-protocol-binding.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ format][ce-event-format].
5353

5454
### 1.3. Content Modes
5555

56-
The [CloudEvents specification][ce-message] defines two content modes for
57-
transferring events: _structured_ and _binary_.
56+
The [CloudEvents specification][ce-message] defines three content modes for
57+
transferring events: _structured_, _binary_ and _batch_.
5858

5959
Because of the nature of WebSockets messages, this specification supports only
6060
_structured_ data mode, hence event metadata attributes and event data are

cloudevents/formats/avro-format.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ This specification does not define an envelope format. The Avro type system's
2727
intent is primarily to provide a consistent type system for Avro itself and not
2828
for message payloads.
2929

30+
The Avro event format does not currently define a batch mode format.
31+
3032
### 1.1. Conformance
3133

3234
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",

cloudevents/formats/json-format.md

-5
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,6 @@ In the _JSON Batch Format_ several CloudEvents are batched into a single JSON
423423
document. The document is a JSON array filled with CloudEvents in the [JSON
424424
Event format][json-format].
425425

426-
Although the _JSON Batch Format_ builds ontop of the _JSON Format_, it is
427-
considered as a separate format: a valid implementation of the _JSON Format_
428-
doesn't need to support it. The _JSON Batch Format_ MUST NOT be used when only
429-
support for the _JSON Format_ is indicated.
430-
431426
### 4.1. Mapping CloudEvents
432427

433428
This section defines how a batch of CloudEvents is mapped to JSON.

cloudevents/formats/protobuf-format.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,9 @@ Transports that support content identification MUST use the following designatio
135135

136136
## 5. Batch Format
137137

138-
Batch format allows for a set of CloudEvents to be represented, no relationship
139-
between those events is implied.
140-
141-
Although the _protobuf batch format_ builds on the _protobuf format_ it is considered
142-
separate, that is to say that support of _protobuf format_ does not indicate support
143-
of the batch representation. The batch format MUST only be used where supported.
138+
In the _Protobuf Batch Format_ several CloudEvents are batched into a single Protobuf
139+
message. The message contains a repeated field filled with independent CloudEvent messages
140+
in the structured mode Protobuf event format.
144141

145142
### 5.1 Envelope
146143

@@ -242,7 +239,6 @@ private static Spec.CloudEvent protoExample() {
242239
[proto-wellknown]: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
243240
[proto-timestamp]: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp
244241
[proto-schema]: ./cloudevents.proto
245-
[json-format]: ./json-format.md
246242
[ce]: ../spec.md
247243
[ce-types]: ../spec.md#type-system
248244
[rfc2119]: https://tools.ietf.org/html/rfc2119

cloudevents/spec.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ Stand-alone event formats, such as the [JSON format](formats/json-format.md),
124124
specify serialization independent of any protocol or storage medium. Protocol
125125
Bindings MAY define formats that are dependent on the protocol.
126126

127+
Each Event Format MUST define a structured-mode representation, and MAY define
128+
a batch-mode representation.
129+
127130
#### Message
128131

129132
Events are transported from a source to a destination via messages.
130133

131134
A "structured-mode message" is one where the entire event (attributes and data)
132-
are encoded in the message body.
135+
are encoded in the message body, according to a specific event format.
133136

134137
A "binary-mode message" is one where the event data is stored in the message
135138
body, and event attributes are stored as part of message metadata.
@@ -142,6 +145,10 @@ metadata typically allows for extension attributes. In other words, a binary
142145
formatted CloudEvent would work for both a CloudEvents enabled receiver as well
143146
as one that is unaware of CloudEvents.
144147

148+
A "batch-mode message" is one where multiple (zero or more) events are
149+
encoded in a single message body, according to a specific event format. Not
150+
all event formats or protocol bindings support batch-mode messages.
151+
145152
#### Protocol
146153

147154
Messages can be delivered through various industry standard protocol (e.g. HTTP,

cloudevents/working-drafts/xml-format.md

-5
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,6 @@ In the _XML Batch Format_ several CloudEvents are batched into a single XML
209209
The `<event>` element MUST NOT contain any direct child text nodes with non-whitespace
210210
content.
211211

212-
Although the _XML Batch Format_ builds on top of the _XML Format_, it is
213-
considered as a separate format: a valid implementation of the _XML Format_
214-
doesn't need to support it. The _XML Batch Format_ MUST NOT be used when only
215-
support for the _XML Format_ is indicated.
216-
217212
An XML Batch of CloudEvents MUST use the media type
218213
`application/cloudevents-batch+xml`.
219214

0 commit comments

Comments
 (0)