diff options
author | Vladimir Lavor <vlavor@cisco.com> | 2021-03-17 12:27:10 +0100 |
---|---|---|
committer | Vladimir Lavor <vlavor@cisco.com> | 2021-05-05 13:26:19 +0200 |
commit | c380ee6064379258768fdfe4e9d4ad9138980ec0 (patch) | |
tree | 28903f9ee23bb3206e21a2c04001ebfc560de944 /adapter/mock | |
parent | a6607d9c1ba37320984c13580c932076cbff6dd6 (diff) |
statsclient: allow index as pattern
* ListStats() returns stats identifiers containing the stat name and index
* New method PrepareDirOnIndex(indexes...). Instead of the name filter
it does not browse through all available indexes
* Stats example shows how to get the last epoch value (added "e" or "epoch" command)
Change-Id: Ibb15090fb0dfdb7f9b0ecf8ac07a5eb9a9ace8f8
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
Diffstat (limited to 'adapter/mock')
-rw-r--r-- | adapter/mock/mock_stats_adapter.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/adapter/mock/mock_stats_adapter.go b/adapter/mock/mock_stats_adapter.go index 55b1831..08d18d4 100644 --- a/adapter/mock/mock_stats_adapter.go +++ b/adapter/mock/mock_stats_adapter.go @@ -46,10 +46,13 @@ func (a *StatsAdapter) Disconnect() error { } // ListStats mocks name listing for all stats. -func (a *StatsAdapter) ListStats(patterns ...string) ([]string, error) { - var statNames []string +func (a *StatsAdapter) ListStats(patterns ...string) ([]adapter.StatIdentifier, error) { + var statNames []adapter.StatIdentifier for _, stat := range a.entries { - statNames = append(statNames, string(stat.Name)) + statNames = append(statNames, adapter.StatIdentifier{ + Name: stat.Name, + Index: stat.Index, + }) } return statNames, nil } @@ -63,6 +66,10 @@ func (a *StatsAdapter) PrepareDir(prefixes ...string) (*adapter.StatDir, error) return a.dir, nil } +func (a *StatsAdapter) PrepareDirOnIndex(indexes ...uint32) (*adapter.StatDir, error) { + return a.dir, nil +} + func (a *StatsAdapter) UpdateDir(dir *adapter.StatDir) error { *dir = *a.dir return nil |