diff options
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) |