Skip to content

altairsix/eventsource-protobuf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eventsource-protobuf

protoc plugin to generate eventsource.Serializers for github.com/altairsix/eventsource

Installation

go get github.com/altairsix/eventsource-protobuf/...

Usage

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

Limitations

  • 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 id
    • int32 version - version
    • int64 at - unix epoch in seconds

Example

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;
}

About

protobuf serializer for github.com/altairsix/eventsource

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages