-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
48 lines (39 loc) · 813 Bytes
/
Copy pathinterface.go
File metadata and controls
48 lines (39 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package iote
import (
"encoding/json"
"fmt"
"net/http"
)
type EventEntity interface {
GetDeviceID() string
ParseBinary([]byte) error
}
type EventAlert struct {
Event EventEntity
Msg string
}
func (ea EventAlert) Error() string {
if ea.Event == nil {
return ea.Msg
}
b, err := json.Marshal(ea.Event)
if err != nil {
return "error marshal json for event alert" + err.Error()
}
return string(b) + " " + ea.Msg
}
type EventInspector interface {
Inspect(entity EventEntity, errChan chan<- error)
ReportService() *EventInspectorService
}
type EventInspectorService struct {
Handler http.HandlerFunc
URI string
}
type EventNotifier interface {
Notify(EventAlert)
}
type ConsoleNotifier struct{}
func (ConsoleNotifier) Notify(ea EventAlert) {
fmt.Println("WARNING: " + ea.Error())
}