events
events/event.go
Add constants, ignore empty data. Add constants for ActionCreated, ActionUpdated, and ActionDeleted, as they'll be used by pretty much everything, and we don't need duplicate definitions in each and every codebase. Add an `omitempty` tag to the Data property of our message, so if there's no data to be associated with a message, we don't send something empty, which would be silly.
1.1 --- a/event.go Fri May 15 22:51:31 2015 -0400 1.2 +++ b/event.go Mon Jul 13 23:52:30 2015 -0400 1.3 @@ -4,11 +4,17 @@ 1.4 "time" 1.5 ) 1.6 1.7 +const ( 1.8 + ActionCreated = "created" 1.9 + ActionUpdated = "updated" 1.10 + ActionDeleted = "deleted" 1.11 +) 1.12 + 1.13 type Event struct { 1.14 System string `json:"system"` 1.15 Model string `json:"model"` 1.16 ID string `json:"id"` 1.17 Action string `json:"action"` 1.18 Timestamp time.Time `json:"timestamp"` 1.19 - Data interface{} `json:"data"` 1.20 + Data interface{} `json:"data,omitempty"` 1.21 }