1package atc 2 3import "strings" 4 5// Event represents an event emitted by a build. They are interpreted as a 6// stream to render the build's output. 7type Event interface { 8 EventType() EventType 9 Version() EventVersion 10} 11 12// EventType is a classification of an event payload, associated to a struct to 13// parse it into. 14type EventType string 15 16// EventVersion is a MAJOR.MINOR version corresponding to an event type. 17// 18// Minor bumps must be backwards-compatible, meaning older clients can still 19// unmarshal them into their old type and still handle the event. 20// 21// An example of a minor bump would be an additive change, i.e. a new field. 22// 23// Major bumps are backwards-incompatible and must be parsed and handled 24// differently. An example of a major bump would be the changing or removal of a 25// field. 26type EventVersion string 27 28// IsCompatibleWith checks whether the versions have the same major version. 29func (version EventVersion) IsCompatibleWith(other EventVersion) bool { 30 segs := strings.SplitN(string(other), ".", 2) 31 return strings.HasPrefix(string(version), segs[0]+".") 32} 33