1 // Package ifcounters provides the helper API for decoding VnetInterfaceCounters binary API message
2 // that contains binary-encoded statistics data into the Go structs that are better consumable by the Go code.
4 // VPP provides two types of interface counters that can be encoded inside of a single VnetInterfaceCounters
5 // message: simple and combined. For both of them, ifcounters API provides a separate decode function:
6 // DecodeCounters or DecodeCombinedCounters. The functions return a slice of simple or combined counters respectively:
8 // notifMsg := <-notifChan:
9 // notif := notifMsg.(*interfaces.VnetInterfaceCounters)
11 // if notif.IsCombined == 0 {
13 // counters, err := ifcounters.DecodeCounters(ifcounters.VnetInterfaceCounters(*notif))
15 // fmt.Println("Error:", err)
17 // fmt.Printf("%+v\n", counters)
20 // // combined counter
21 // counters, err := ifcounters.DecodeCombinedCounters(ifcounters.VnetInterfaceCounters(*notif))
23 // fmt.Println("Error:", err)
25 // fmt.Printf("%+v\n", counters)