Skip to content

Commit

Permalink
lint.
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Nichols <nicholss@google.com>
  • Loading branch information
Scott Nichols committed Apr 14, 2019
2 parents 06e0105 + 3ea7805 commit 5ce93f0
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 5 deletions.
73 changes: 73 additions & 0 deletions extensions/dataref.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Dataref (Claim Check Pattern)

As defined by the term [Data](../spec.md#data), CloudEvents MAY include
domain-specific information about the occurrence. When present, this information
will be encapsulated within the `data` attribute.
The `dataref` attribute MAY be used to reference another location where this
information is stored. The information, whether accessed via `data` or `dataref`
MUST be identical.

Both the `data` and `dataref` attribute MAY exist at the same time. A middleware
MAY drop the `data` attribute when the `dataref` attribute exists, it MAY add
the `dataref` attribute and drop the `data` attribute, or it MAY add the `data`
attribute by using the `dataref` attribute.

## Attributes

### dataref
* Type: `URI-reference`
* Description: A reference to a location where the event payload is stored. The
location MAY not be accessible without further information (e.g. a pre-shared
secret).

Known as the "Claim Check Pattern", this attribute MAY be used for a variety
of purposes, including:

* If the [Data](../spec.md#data) is too large to be included in the message,
the `data` attribute is not present, and the consumer can retrieve it using
this attribute.
* If the consumer wants to verify that the [Data](../spec.md#data) has not
been tampered with, it can retrieve it from a trusted source using this
attribute.
* If the [Data](../spec.md#data) MUST only be viewed by trusted consumers
(e.g. personally identifiable information), only a trusted consumer can
retrieve it using this attribute and a pre-shared secret.

If this attribute is used, the information SHOULD be accessible long enough
for all consumers to retrieve it, but MAY not be stored for an extended period
of time.

* Constraints:
* OPTIONAL

# Examples

The following example shows a CloudEvent in which the event producer has included
both `data` and `dataref` (serialized as JSON):

``` JSON
{
"specversion" : "0.2",
"type" : "com.github.pull.create",
"source" : "https://github.com/cloudevents/spec/pull/123",
"id" : "A234-1234-1234",
"datacontenttype" : "text/xml",
"data" : "<much wow=\"xml\"/>",
"dataref" : "https://github.com/cloudevents/spec/pull/123/events/A234-1234-1234.xml"
}
```

The following example shows a CloudEvent in which a middleware has replaced the
`data` with a `dataref` (serialized as JSON):

``` JSON
{
"specversion" : "0.2",
"type" : "com.github.pull.create",
"source" : "https://github.com/cloudevents/spec/pull/123",
"id" : "A234-1234-1234",
"datacontenttype" : "text/xml",
"dataref" : "https://tenant123.middleware.com/events/data/A234-1234-1234.xml"
}
```

2 changes: 1 addition & 1 deletion json-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The following table shows exemplary mappings:
| CloudEvents | Type | Exemplary JSON Value |
| --------------- | ------------- | ------------------------------- |
| type | String | "com.example.someevent" |
| specversion | String | "0.3-wip" |
| specversion | String | "0.3-wip" |
| source | URI-reference | "/mycontext" |
| id | String | "1234-1234-1234" |
| time | Timestamp | "2018-04-05T17:31:00Z" |
Expand Down
41 changes: 37 additions & 4 deletions spec.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CloudEvents - Version 0.3-wip

=======

## Abstract

CloudEvents is a vendor-neutral specification for defining the format of event
Expand Down Expand Up @@ -196,11 +198,41 @@ within the same JSON object.
- Constraints:
- REQUIRED
- Examples
- https://github.com/cloudevents/spec/pull/123
- /cloudevents/spec/pull/123
- urn:event:from:myapi/resourse/123
- https://github.com/cloudevents/spec/pull
- /cloudevents/spec/pull
- urn:event:from:myapi/resource
- mailto:cncf-wg-serverless@lists.cncf.io

### subject

- Type: `String`
- Description: This describes the subject of the event in the context of the
event producer (identified by `source`). In publish-subscribe scenarios, a
subscriber will typically subscribe to events emitted by a `source`, but the
`source` identifier alone might not be sufficient as a qualifier for any
specific event if the `source` context has internal sub-structure.

Identifying the subject of the event in context metadata (opposed to only in
the `data` payload) is particularly helpful in generic subscription filtering
scenarios where middleware is unable to interpret the `data` content. In the
above example, the subscriber might only be interested in blobs with names
ending with '.jpg' or '.jpeg' and the `subject` attribute allows for
constructing a simple and efficient string-suffix filter for that subset of
events.

- Constraints:
- OPTIONAL
- If present, MUST be a non-empty string
- Example:
- A subscriber might register interest for when new blobs are created inside a
blob-storage container. In this case, the event `source` identifies the
subscription scope (storage container), the `type` identifies the "blob
created" event, and the `id` uniquely identifies the event instance to
distinguish separate occurrences of a same-named blob having been created;
the name of the newly created blob is carried in `subject`:
- `source`: https://example.com/storage/tenant/container
- `subject`: mynewfile.jpg

### id

- Type: `String`
Expand Down Expand Up @@ -373,7 +405,8 @@ The following example shows a CloudEvent serialized as JSON:
{
"specversion" : "0.3-wip",
"type" : "com.github.pull.create",
"source" : "https://github.com/cloudevents/spec/pull/123",
"source" : "https://github.com/cloudevents/spec/pull",
"subject" : "123",
"id" : "A234-1234-1234",
"time" : "2018-04-05T17:31:00Z",
"comexampleextension1" : "value",
Expand Down

0 comments on commit 5ce93f0

Please sign in to comment.