Fix socketclient for VPP 19.08
[govpp.git] / adapter / stats_api.go
index 3538176..90ecd78 100644 (file)
 package adapter
 
 import (
+       "errors"
        "fmt"
 )
 
+const (
+       // DefaultStatsSocket defines a default socket file path for VPP stats API.
+       DefaultStatsSocket = "/run/vpp/stats.sock"
+)
+
+var (
+       ErrStatDirBusy  = errors.New("stat dir busy")
+       ErrStatDumpBusy = errors.New("stat dump busy")
+)
+
 // StatsAPI provides connection to VPP stats API.
 type StatsAPI interface {
        // Connect establishes client connection to the stats API.
@@ -39,10 +50,11 @@ type StatType int
 
 const (
        _                     StatType = 0
-       ScalarIndex                    = 1
-       SimpleCounterVector            = 2
-       CombinedCounterVector          = 3
-       ErrorIndex                     = 4
+       ScalarIndex           StatType = 1
+       SimpleCounterVector   StatType = 2
+       CombinedCounterVector StatType = 3
+       ErrorIndex            StatType = 4
+       NameVector            StatType = 5
 )
 
 func (d StatType) String() string {
@@ -55,6 +67,8 @@ func (d StatType) String() string {
                return "CombinedCounterVector"
        case ErrorIndex:
                return "ErrorIndex"
+       case NameVector:
+               return "NameVector"
        }
        return fmt.Sprintf("UnknownStatType(%d)", d)
 }
@@ -76,11 +90,14 @@ type CombinedCounter struct {
        Bytes   Counter
 }
 
+// Name represents string value stored under name vector.
+type Name string
+
 // ScalarStat represents stat for ScalarIndex.
 type ScalarStat float64
 
 // ErrorStat represents stat for ErrorIndex.
-type ErrorStat uint64
+type ErrorStat Counter
 
 // SimpleCounterStat represents stat for SimpleCounterVector.
 // The outer array represents workers and the inner array represents interface/node/.. indexes.
@@ -92,6 +109,9 @@ type SimpleCounterStat [][]Counter
 // Values should be aggregated per interface/node for every worker.
 type CombinedCounterStat [][]CombinedCounter
 
+// NameStat represents stat for NameVector.
+type NameStat []Name
+
 // Data represents some type of stat which is usually defined by StatType.
 type Stat interface {
        // isStat is unexported to limit implementations of Data interface to this package,
@@ -102,3 +122,4 @@ func (ScalarStat) isStat()          {}
 func (ErrorStat) isStat()           {}
 func (SimpleCounterStat) isStat()   {}
 func (CombinedCounterStat) isStat() {}
+func (NameStat) isStat()            {}