Skip to content

Commit c90c905

Browse files
committed
Improve sequence extension documentation
Signed-off-by: Yordis Prieto <[email protected]> fixes #1366
1 parent c26a694 commit c90c905

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

cloudevents/extensions/sequence.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ value comes first.
1414
Produces and consumers are free to define an out-of-band agreement on the
1515
semantic meaning, or valid values, for the attribute.
1616

17+
If sequence comparison across multiple dimensions is required (e.g., per source
18+
AND subject), implementers have two options:
19+
- Include the additional dimension in the `source` attribute value
20+
(e.g., `"source": "https://example.com/users/service/subject123"`)
21+
- Define a new extension that meets their specific sequencing requirements
22+
1723
## Notational Conventions
1824

1925
As with the main [CloudEvents specification](../spec.md), the key words "MUST",
@@ -31,8 +37,8 @@ this extension is being used.
3137
### sequence
3238

3339
- Type: `String`
34-
- Description: Value expressing the relative order of the event. This enables
35-
interpretation of data supercedence.
40+
- Description: Value expressing the relative order of the event within the scope
41+
of its `source` attribute.
3642
- Constraints
3743
- REQUIRED
3844
- MUST be a non-empty lexicographically-orderable string
@@ -44,3 +50,39 @@ can determine the order of the events via a simple string-compare type of
4450
operation. This means that it might be necessary for the value to include
4551
some kind of padding (e.g. leading zeros in the case of the value being the
4652
string representation of an integer).
53+
54+
## Examples
55+
56+
### Valid Usage
57+
58+
Events from the same source with properly ordered sequences:
59+
60+
```json
61+
{
62+
"source": "https://example.com/users/service",
63+
"sequence": "001",
64+
"id": "event-1"
65+
}
66+
67+
{
68+
"source": "https://example.com/users/service",
69+
"sequence": "002",
70+
"id": "event-2"
71+
}
72+
```
73+
74+
The second event comes after the first (`"002" > "001"`).
75+
76+
### Invalid Cross-Source Comparison
77+
78+
```json
79+
{
80+
"source": "https://example.com/users/service",
81+
"sequence": "005"
82+
}
83+
84+
{
85+
"source": "https://example.com/orders/service",
86+
"sequence": "003"
87+
}
88+
```

0 commit comments

Comments
 (0)