3 // StatsAPI provides connection to VPP stats API.
4 type StatsAPI interface {
5 // Connect establishes client connection to the stats API.
8 // Disconnect terminates client connection.
11 // ListStats lists names for all stats.
12 ListStats(patterns ...string) (statNames []string, err error)
14 // DumpStats dumps all stat entries.
15 DumpStats(patterns ...string) ([]*StatEntry, error)
18 // StatType represents type of stat directory and simply
19 // defines what type of stat data is stored in the stat entry.
30 func (d StatType) String() string {
34 case SimpleCounterVector:
35 return "SimpleCounterVector"
36 case CombinedCounterVector:
37 return "CombinedCounterVector"
41 return "UnknownStatType"
44 // StatEntry represents single stat entry. The type of stat stored in Data
45 // is defined by Type.
46 type StatEntry struct {
52 // Counter represents simple counter with single value.
55 // CombinedCounter represents counter with two values, for packet count and bytes count.
56 type CombinedCounter struct {
61 // ScalarStat represents stat for ScalarIndex.
62 type ScalarStat float64
64 // ErrorStat represents stat for ErrorIndex.
67 // SimpleCounterStat represents stat for SimpleCounterVector.
68 // The outer array represents workers and the inner array represents sw_if_index.
69 // Values should be aggregated per interface for every worker.
70 type SimpleCounterStat [][]Counter
72 // CombinedCounterStat represents stat for CombinedCounterVector.
73 // The outer array represents workers and the inner array represents sw_if_index.
74 // Values should be aggregated per interface for every worker.
75 type CombinedCounterStat [][]CombinedCounter
77 // Data represents some type of stat which is usually defined by StatType.
79 // isStat is unexported to limit implementations of Data interface to this package,
83 func (ScalarStat) isStat() {}
84 func (ErrorStat) isStat() {}
85 func (SimpleCounterStat) isStat() {}
86 func (CombinedCounterStat) isStat() {}