Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf specification rework #131

Merged
merged 17 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions docs/serialisation/protobuf.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,12 @@ message Foo {

### Documents

Documents should be serialised using a protobuf message equivalent to the one below :
Documents should be serialised using a protobuf message equivalent to the [`google.protobuf.Value`](https://github.com/protocolbuffers/protobuf/blob/5ecfdd76ef25f069cd84fac0b0fb3b95e2d61a34/src/google/protobuf/struct.proto#L62) type, which is commonly used in the protobuf ecosystem to represent [JSON values](https://protobuf.dev/reference/protobuf/google.protobuf/#value).

```proto
message DNull {
}

message DArray {
repeated Document values = 1;
}

message DObject {
map<string, Document> values = 1;
}
### Timestamp

message Document {
oneof value {
DNull dNull = 1;
bool dBoolean = 2;
double dNumber = 3;
string dString = 4;
DArray dArray = 5;
DObject dObject = 6;
}
}
```
Documents should be serialised using a protobuf message equivalent to the [`google.protobuf.Timestamp`](https://github.com/protocolbuffers/protobuf/blob/5ecfdd76ef25f069cd84fac0b0fb3b95e2d61a34/src/google/protobuf/timestamp.proto#L133) type, which is commonly used in the protobuf ecosystem to represent [Timestamp values](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp).
Baccata marked this conversation as resolved.
Show resolved Hide resolved

For convenience, alloy provides this proto definition in a jar publised to maven-central `alloy-protobuf`

### Aggregate Types

Expand Down
27 changes: 0 additions & 27 deletions modules/protobuf/resources/alloy/protobuf/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,3 @@ message CompactUUID {
int64 upper_bits = 1;
int64 lower_bits = 2;
}

message Timestamp {
int64 seconds = 1;
int64 nanos = 2;
}

message DNull {
}

message DArray {
repeated Document values = 1;
}

message DObject {
map<string, Document> values = 1;
}

message Document {
oneof value {
DNull dNull = 1;
bool dBoolean = 2;
double dNumber = 3;
string dString = 4;
DArray dArray = 5;
DObject dObject = 6;
}
}
7 changes: 5 additions & 2 deletions modules/protobuf/resources/alloy/protobuf/wrappers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ syntax = "proto3";

package alloy.protobuf;

import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

import "alloy/protobuf/types.proto";

message TimestampValue {
alloy.protobuf.Timestamp value = 1;
google.protobuf.Timestamp value = 1;
}

message DocumentValue {
alloy.protobuf.Document value = 1;
google.protobuf.Value value = 1;
}

message CompactUUIDValue {
Expand Down
Loading