events

Paddy 2015-07-13 Parent:2e19675ea220 Child:ce1212549d47

1:e86251b04826 Go to Latest

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.

History
1 package events
3 import (
4 "time"
5 )
7 const (
8 ActionCreated = "created"
9 ActionUpdated = "updated"
10 ActionDeleted = "deleted"
11 )
13 type Event struct {
14 System string `json:"system"`
15 Model string `json:"model"`
16 ID string `json:"id"`
17 Action string `json:"action"`
18 Timestamp time.Time `json:"timestamp"`
19 Data interface{} `json:"data,omitempty"`
20 }