-
Notifications
You must be signed in to change notification settings - Fork 51
/
collector.go
53 lines (45 loc) · 1.23 KB
/
collector.go
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
49
50
51
52
53
package statscollector
import (
"sync"
"go.aporeto.io/enforcerd/trireme-lib/collector"
)
// NewCollector provides a new collector interface
func NewCollector() Collector {
return &collectorImpl{
Flows: map[uint64]*collector.FlowRecord{},
Users: map[string]*collector.UserRecord{},
ProcessedUsers: map[string]bool{},
Reports: make(chan *Report, 1000),
}
}
// collectorImpl : This object is a stash implements two interfaces.
//
// collector.EventCollector - so datapath can report flow events
// CollectorReader - so components can extract information out of this stash
//
// It has a flow entries cache which contains unique flows that are reported
// back to the controller/launcher process
type collectorImpl struct {
Flows map[uint64]*collector.FlowRecord
ProcessedUsers map[string]bool
Users map[string]*collector.UserRecord
Reports chan *Report
sync.Mutex
}
// ReportType it the type of report.
type ReportType uint8
// ReportTypes.
const (
FlowRecord ReportType = iota
UserRecord
PacketReport
CounterReport
DNSReport
PingReport
ConnectionExceptionReport
)
// Report holds the report type and the payload.
type Report struct {
Type ReportType
Payload interface{}
}