diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-06-20 18:52:30 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-06-20 18:52:30 +0200 |
commit | da15c397b3dbbba07d159b3af767aa13d443cfd6 (patch) | |
tree | 284e4207377df3c0952656d4f75459a96d0ecb36 /adapter/vppapiclient | |
parent | 682250e328472e855a4c59e9e5f004473b6af0d3 (diff) |
Add statsclient - pure Go implementation for stats API
Change-Id: Ia5bab652c6089378697459f477f9060dc7a53e90
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'adapter/vppapiclient')
-rw-r--r-- | adapter/vppapiclient/stat_client.go | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/adapter/vppapiclient/stat_client.go b/adapter/vppapiclient/stat_client.go index 389c93b..148f618 100644 --- a/adapter/vppapiclient/stat_client.go +++ b/adapter/vppapiclient/stat_client.go @@ -25,7 +25,6 @@ package vppapiclient import "C" import ( - "errors" "fmt" "os" "unsafe" @@ -33,21 +32,11 @@ import ( "git.fd.io/govpp.git/adapter" ) -var ( - ErrStatDirBusy = errors.New("stat dir busy") - ErrStatDumpBusy = errors.New("stat dump busy") -) - -var ( - // DefaultStatSocket is the default path for the VPP stat socket file. - DefaultStatSocket = "/run/vpp/stats.sock" -) - // global VPP stats API client, library vppapiclient only supports // single connection at a time var globalStatClient *statClient -// stubStatClient is the default implementation of StatsAPI. +// statClient is the default implementation of StatsAPI. type statClient struct { socketName string } @@ -66,7 +55,7 @@ func (c *statClient) Connect() error { var sockName string if c.socketName == "" { - sockName = DefaultStatSocket + sockName = adapter.DefaultStatsSocket } else { sockName = c.socketName } @@ -97,7 +86,7 @@ func (c *statClient) Disconnect() error { func (c *statClient) ListStats(patterns ...string) (stats []string, err error) { dir := C.govpp_stat_segment_ls(convertStringSlice(patterns)) if dir == nil { - return nil, ErrStatDirBusy + return nil, adapter.ErrStatDirBusy } defer C.govpp_stat_segment_vec_free(unsafe.Pointer(dir)) @@ -114,13 +103,13 @@ func (c *statClient) ListStats(patterns ...string) (stats []string, err error) { func (c *statClient) DumpStats(patterns ...string) (stats []*adapter.StatEntry, err error) { dir := C.govpp_stat_segment_ls(convertStringSlice(patterns)) if dir == nil { - return nil, ErrStatDirBusy + return nil, adapter.ErrStatDirBusy } defer C.govpp_stat_segment_vec_free(unsafe.Pointer(dir)) dump := C.govpp_stat_segment_dump(dir) if dump == nil { - return nil, ErrStatDumpBusy + return nil, adapter.ErrStatDumpBusy } defer C.govpp_stat_segment_data_free(dump) |