github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/controller/pkg/remoteenforcer/internal/statscollector/collector.go (about)

     1  package statscollector
     2  
     3  import (
     4  	"sync"
     5  
     6  	"go.aporeto.io/enforcerd/trireme-lib/collector"
     7  )
     8  
     9  // NewCollector provides a new collector interface
    10  func NewCollector() Collector {
    11  	return &collectorImpl{
    12  		Flows:          map[uint64]*collector.FlowRecord{},
    13  		Users:          map[string]*collector.UserRecord{},
    14  		ProcessedUsers: map[string]bool{},
    15  		Reports:        make(chan *Report, 1000),
    16  	}
    17  }
    18  
    19  // collectorImpl : This object is a stash implements two interfaces.
    20  //
    21  //  collector.EventCollector - so datapath can report flow events
    22  //  CollectorReader - so components can extract information out of this stash
    23  //
    24  // It has a flow entries cache which contains unique flows that are reported
    25  // back to the controller/launcher process
    26  type collectorImpl struct {
    27  	Flows          map[uint64]*collector.FlowRecord
    28  	ProcessedUsers map[string]bool
    29  	Users          map[string]*collector.UserRecord
    30  	Reports        chan *Report
    31  
    32  	sync.Mutex
    33  }
    34  
    35  // ReportType it the type of report.
    36  type ReportType uint8
    37  
    38  // ReportTypes.
    39  const (
    40  	FlowRecord ReportType = iota
    41  	UserRecord
    42  	PacketReport
    43  	CounterReport
    44  	DNSReport
    45  	PingReport
    46  	ConnectionExceptionReport
    47  )
    48  
    49  // Report holds the report type and the payload.
    50  type Report struct {
    51  	Type    ReportType
    52  	Payload interface{}
    53  }