Skip to content

Commit 2189ab3

Browse files
clemensvDoug Davis
authored andcommitted
type system (#152)
Signed-off-by: Clemens Vasters <clemensv@microsoft.com>
1 parent 9ca339d commit 2189ab3

1 file changed

Lines changed: 29 additions & 10 deletions

File tree

spec.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ Messages can be delivered through various industry standard protocol (e.g. HTTP,
251251
AMQP, MQTT, SMTP), open-source protocols (e.g. Kafka, NATS), or
252252
platform/vendor specific protocols (AWS Kinesis, Azure Event Grid).
253253

254+
## Type System
255+
256+
The following abstract data types are available for use in attributes.
257+
258+
- `String` - Sequence of printable Unicode characters.
259+
- `Binary` - Sequence of bytes.
260+
- `Map` - `String`-indexed dictionary of `Object`-typed values
261+
- `Object` - Either a `String`, or a `Binary`, or a `Map`
262+
- `URI` - String expression as defined in
263+
[RFC 3986](https://tools.ietf.org/html/rfc3986)
264+
- `Timestamp` - String expression as defined in
265+
[RFC 3339](https://tools.ietf.org/html/rfc3339)
266+
267+
This specification does not define numeric or logical types.
268+
269+
The `Object` type is a variant type that can take the shape of either a
270+
`String` or a `Binary` or a `Map`. The type system is intentionally
271+
abstract, and therefore it is left to implementations how to represent the
272+
variant type.
254273

255274
## Context Attributes
256275
Every event conforming to this specification MUST include a context.
@@ -263,7 +282,7 @@ data for some use cases (e.g. a JSON implementation might use one JSON object
263282
that contains both context and data).
264283

265284
### eventType
266-
* Type: String
285+
* Type: `String`
267286
* Description: Type of occurrence which has happened. Often this
268287
property is used for routing, observability, policy enforcement, etc.
269288
* Constraints:
@@ -275,7 +294,7 @@ that contains both context and data).
275294
* com.github.pull.create
276295

277296
### eventTypeVersion
278-
* Type: String
297+
* Type: `String`
279298
* Description: The version of the `eventType`. This enables the interpretation
280299
of `data` by eventual consumers, requires the consumer to be knowledgeable
281300
about the producer.
@@ -284,15 +303,15 @@ that contains both context and data).
284303
* If present, MUST be a non-empty string
285304

286305
### cloudEventsVersion
287-
* Type: String
306+
* Type: `String`
288307
* Description: The version of the CloudEvents specification which the event
289308
uses. This enables the interpretation of the context.
290309
* Constraints:
291310
* REQUIRED
292311
* MUST be a non-empty string
293312

294313
### source
295-
* Type: URI
314+
* Type: `URI`
296315
* Description: This describes the event producer. Often this will include
297316
information such as the type of the event source, the organization
298317
publishing the event, and some unique idenfitiers. The exact syntax and
@@ -301,7 +320,7 @@ that contains both context and data).
301320
* REQUIRED
302321

303322
### eventID
304-
* Type: String
323+
* Type: `String`
305324
* Description: ID of the event. The semantics of this string are explicitly
306325
undefined to ease the implementation of producers. Enables deduplication.
307326
* Examples:
@@ -312,23 +331,23 @@ that contains both context and data).
312331
* MUST be unique within the scope of the producer
313332

314333
### eventTime
315-
* Type: Timestamp per [RFC 3339](https://tools.ietf.org/html/rfc3339)
334+
* Type: `Timestamp`
316335
* Description: Timestamp of when the event happened.
317336
* Constraints:
318337
* OPTIONAL
319338
* If present, MUST adhere to the format specified in
320339
[RFC 3339](https://tools.ietf.org/html/rfc3339)
321340

322341
### schemaURL
323-
* Type: URI per [RFC 3986](https://tools.ietf.org/html/rfc3986)
342+
* Type: `URI`
324343
* Description: A link to the schema that the `data` attribute adheres to.
325344
* Constraints:
326345
* OPTIONAL
327346
* If present, MUST adhere to the format specified in
328347
[RFC 3986](https://tools.ietf.org/html/rfc3986)
329348

330349
### contentType
331-
* Type: String per [RFC 2046](https://tools.ietf.org/html/rfc2046)
350+
* Type: `String` per [RFC 2046](https://tools.ietf.org/html/rfc2046)
332351
* Description: Describe the data encoding format
333352
* Constraints:
334353
* OPTIONAL
@@ -337,7 +356,7 @@ that contains both context and data).
337356
* For Media Type examples see [IANA Media Types](http://www.iana.org/assignments/media-types/media-types.xhtml)
338357

339358
### extensions
340-
* Type: Map <String, Object>
359+
* Type: `Map`
341360
* Description: This is for additional metadata and this does not have a
342361
mandated structure. This enables a place for custom fields a producer or
343362
middleware might want to include and provides a place to test metadata before
@@ -351,7 +370,7 @@ that contains both context and data).
351370
* authorization data
352371

353372
### data
354-
* Type: Arbitrary payload
373+
* Type: `Object`
355374
* Description: The event payload. The payload depends on the eventType,
356375
schemaURL and eventTypeVersion, the payload is encoded into a media format
357376
which is specified by the contentType attribute (e.g. application/json).

0 commit comments

Comments
 (0)