...
1 package event
2
3 import (
4 "encoding/json"
5 )
6
7
8 type Event struct {
9 Channel string `json:"channel"`
10 Operation interface{} `json:"operation"`
11 ClusterInfraClusterEdgeID interface{} `json:"cluster_infra_cluster_edge_id"`
12 BannerEdgeID interface{} `json:"banner_edge_id"`
13 Data interface{} `json:"data"`
14 }
15
16
17 func New() *Event {
18 return &Event{}
19 }
20
21
22 func (e *Event) Unmarshal(channel, event string) (*Event, error) {
23 err := json.Unmarshal([]byte(event), e)
24 e.Channel = channel
25 return e, err
26 }
27
28
29 func (e *Event) ToByte() ([]byte, error) {
30 return json.Marshal(e)
31 }
32
View as plain text