-
Notifications
You must be signed in to change notification settings - Fork 51
/
collector_reader.go
57 lines (44 loc) · 1.08 KB
/
collector_reader.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
54
55
56
57
package statscollector
import (
"go.aporeto.io/enforcerd/trireme-lib/collector"
)
// Count returns the current number of records collected.
func (c *collectorImpl) Count() int {
c.Lock()
defer c.Unlock()
return len(c.Flows)
}
// GetFlowRecords should return all flow records stashed so far.
func (c *collectorImpl) GetFlowRecords() map[uint64]*collector.FlowRecord {
c.Lock()
defer c.Unlock()
if len(c.Flows) == 0 {
return nil
}
retval := c.Flows
c.Flows = make(map[uint64]*collector.FlowRecord)
return retval
}
// GetUserRecords retrieves all the user records.
func (c *collectorImpl) GetUserRecords() map[string]*collector.UserRecord {
c.Lock()
defer c.Unlock()
if len(c.Users) == 0 {
return nil
}
retval := c.Users
c.Users = map[string]*collector.UserRecord{}
return retval
}
// FlushUserCache flushes the user cache.
func (c *collectorImpl) FlushUserCache() {
c.Lock()
defer c.Unlock()
c.ProcessedUsers = map[string]bool{}
}
// GetReports returns reports channel.
func (c *collectorImpl) GetReports() chan *Report {
c.Lock()
defer c.Unlock()
return c.Reports
}