protoc plugin to generate eventsource.Serializers for github.com/altairsix/eventsource
go get github.com/altairsix/eventsource-protobuf/...
The simplest usage is to use eventsource-protobuf is along side your protoc go:generate line.
//go:generate protoc --go_out=. events.proto
//go:generate protoc --eventsource_out=. events.proto
- All events must be defined as protobuf messages
- All events must be defined in a single .proto file
- One message must be the container, effectively a union type with the following:
int32 type = 1;
- Each event must be included in this message
- Each event must the following fields defined:
string id
- aggregate idint32 version
- versionint64 at
- unix epoch in seconds
The following provides a simple example of a .proto that adheres to all the stated requirements.
message ItemAdded {
string id = 1;
int32 version = 2;
int64 at = 3;
}
message ItemRemoved {
string id = 1;
int32 version = 2;
int64 at = 3;
}
// Events
message Events {
int32 type = 1;
ItemAdded a = 2;
ItemRemoved b = 3;
}