Skip to content

Commit c62b56a

Browse files
committed
fix(protobuf): Expose CloudEvent structure with explicit fields
Previously, all optional CloudEvent attributes were hidden within a generic map structure alongside extension attributes. Signed-off-by: Yordis Prieto <[email protected]>
1 parent 94c622d commit c62b56a

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

cloudevents/formats/cloudevents.proto

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* CloudEvent Protobuf Format
33
*
44
* - Required context attributes are explicitly represented.
5-
* - Optional and Extension context attributes are carried in a map structure.
5+
* - Optional context attributes are explicitly represented.
6+
* - Extension context attributes are carried in a map structure.
67
* - Data may be represented as binary, text, or protobuf messages.
78
*/
89

@@ -21,49 +22,44 @@ option php_namespace = "Io\\CloudEvents\\V1\\Proto";
2122
option ruby_package = "Io::CloudEvents::V1::Proto";
2223

2324
message CloudEvent {
24-
25-
// -- CloudEvent Context Attributes
26-
27-
// Required Attributes
2825
string id = 1;
29-
string source = 2; // URI-reference
26+
string source = 2;
3027
string spec_version = 3;
3128
string type = 4;
3229

33-
// Optional & Extension Attributes
34-
map<string, CloudEventAttributeValue> attributes = 5;
30+
optional string datacontenttype = 5;
31+
optional string dataschema = 6;
32+
optional string subject = 7;
33+
optional google.protobuf.Timestamp time = 8;
3534

36-
// -- CloudEvent Data (Bytes, Text, or Proto)
37-
oneof data {
38-
bytes binary_data = 6;
39-
string text_data = 7;
40-
google.protobuf.Any proto_data = 8;
35+
map<string, CloudEventAttributeValue> extensions = 9;
36+
37+
oneof data {
38+
bytes binary_data = 10;
39+
string text_data = 11;
40+
google.protobuf.Any proto_data = 12;
4141
}
4242

4343
/**
4444
* The CloudEvent specification defines
4545
* seven attribute value types...
4646
*/
47-
4847
message CloudEventAttributeValue {
49-
5048
oneof attr {
51-
bool ce_boolean = 1;
52-
int32 ce_integer = 2;
53-
string ce_string = 3;
54-
bytes ce_bytes = 4;
55-
string ce_uri = 5;
56-
string ce_uri_ref = 6;
57-
google.protobuf.Timestamp ce_timestamp = 7;
49+
bool bool_value = 1;
50+
int32 integer_value = 2;
51+
string string_value = 3;
52+
bytes bytes_value = 4;
53+
string uri_value = 5;
54+
string uri_ref_value = 6;
55+
google.protobuf.Timestamp timestamp_value = 7;
5856
}
5957
}
6058
}
6159

6260
/**
6361
* CloudEvent Protobuf Batch Format
64-
*
6562
*/
66-
6763
message CloudEventBatch {
6864
repeated CloudEvent events = 1;
6965
}

0 commit comments

Comments
 (0)