Skip to content

Commit

Permalink
docs: Expand versioning suggestions
Browse files Browse the repository at this point in the history
Addresses #778

Signed-off-by: Jon Skeet <jonskeet@google.com>
  • Loading branch information
jskeet committed Apr 1, 2021
1 parent c856ea1 commit 589a415
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 20 deletions.
67 changes: 49 additions & 18 deletions primer.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This document is a working draft.
- [CloudEvents Concepts](#cloudevents-concepts)
- [Design Goals](#design-goals)
- [Architecture](#architecture)
- [Versioning of Attributes](#versioning-of-attributes)
- [Versioning of CloudEvents](#versioning-of-cloudevents)
- [CloudEvent Attributes](#cloudevent-attributes)
- [CloudEvent Attribute Extensions](#cloudevent-attribute-extensions)
- [Creating CloudEvents](#creating-cloudevents)
Expand Down Expand Up @@ -238,23 +238,54 @@ there are errors during the processing of a CloudEvent, the software
encountering the error is encouraged to use the normal protocol-level error
reporting to report them.

## Versioning of Attributes

For certain CloudEvents attributes, the entity or data model referenced by its
value might change over time. For example, `dataschema` might reference one
particular version of a schema document. Often these attribute values will then
distinguish each variant by including some version-specific string as part of
its value. For example, a version number (`v1`, `v2`), or a date (`2018-01-01`)
might be used.

The CloudEvents specification does not mandate any particular pattern to be
used, or even the use of version strings at all. This decision is up to each
event producer. However, when a version-specific string is included, care should
be taken whenever its value changes as event consumers might be reliant on the
existing value and thus a change could be interpreted as a "breaking change".
Some form of communication between producers and consumers should be established
to ensure the event consumers know what possible values might be used. In
general, this is true for all CloudEvents attributes as well.
## Versioning of CloudEvents

For many CloudEvents, the schema of the data within the event might
change over time. The CloudEvents specification does not mandate any
particular pattern to be used, or even the use or consideration of
versioning at all. This decision is up to each event producer.

However, event producers are encouraged to consider how they might
evolve their schema without breaking consumers. Two specific
context attributes are particularly important in this respect, but
differ in expected usage: `type` and `dataschema`.

The `type` attribute is expected to be the primary means by which
consumers identify the type of event that they receive. This could
be achieved by subscribing to a specific CloudEvent type, or by
filtering all received CloudEvents by type locally. But consumers
who have identified a CloudEvent type will generally expect the data
within that type to only change in backwardly-compatible ways,
unless clearly indicated otherwise. The precise meaning of
"backwardly-compatible" will vary by data content type.

The `dataschema` attribute is expected to be informational, largely
to be used during development and by tooling that is able to provide
diagnostic information over arbitrary CloudEvents with a data
content type understood by that tooling.

When a CloudEvent's data changes in a backwardly-compatible way, the
value of the `type` attribute should generally stay the same. The
value of the `dataschema` attribute may change, or it may stay the
same but the content served from the URI can change to reflect the
updated schema.

When a CloudEvent's data changes in a backwardly-incompatible way,
the value of the `type` attribute should generally change. The event
producer is encouraged to produce both the old event and the new
event for some time (potentially forever) in order to avoid
disrupting consumers.

When considering the value of the `type` attribute, event producers
may choose any versioning scheme they wish, such as a version number
(`v1`, `v2`) or a date (`2018-01-01`) as part of the value. They may
also use the `type` attribute to convey that a particular version is
not yet stable, and may take breaking change.

Event producers are encouraged to consider versioning from the
outset, before first declaring a particular CloudEvent to be
"stable". Documentation of the chosen versioning scheme, including
the rationale behind it, is likely to be appreciated by consumers.

## CloudEvent Attributes

Expand Down
4 changes: 2 additions & 2 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ The following attributes are REQUIRED to be present in all CloudEvents:
routing, observability, policy enforcement, etc. The format of this is
producer defined and might include information such as the version of the
`type` - see
[Versioning of Attributes in the Primer](primer.md#versioning-of-attributes)
[Versioning of CloudEvents in the Primer](primer.md#versioning-of-cloudevents)
for more information.
- Constraints:
- REQUIRED
Expand Down Expand Up @@ -380,7 +380,7 @@ on the definition of OPTIONAL.
- Type: `URI`
- Description: Identifies the schema that `data` adheres to. Incompatible
changes to the schema SHOULD be reflected by a different URI. See
[Versioning of Attributes in the Primer](primer.md#versioning-of-attributes)
[Versioning of CloudEvents in the Primer](primer.md#versioning-of-cloudevents)
for more information.
- Constraints:
- OPTIONAL
Expand Down

0 comments on commit 589a415

Please sign in to comment.