Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Adds the ability to describe namespace elements without using labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jcooklin committed Apr 18, 2016
1 parent 7ff2686 commit 10d107e
Show file tree
Hide file tree
Showing 31 changed files with 486 additions and 427 deletions.
28 changes: 14 additions & 14 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ type managesPlugins interface {
}

type catalogsMetrics interface {
Get([]string, int) (*metricType, error)
GetQueriedNamespaces([]string) ([][]string, error)
MatchQuery([]string) ([][]string, error)
Get(core.Namespace, int) (*metricType, error)
GetQueriedNamespaces(core.Namespace) ([]core.Namespace, error)
MatchQuery(core.Namespace) ([]core.Namespace, error)
Add(*metricType)
AddLoadedMetricType(*loadedPlugin, core.Metric) error
RmUnloadedPluginMetrics(lp *loadedPlugin)
GetVersions([]string) ([]*metricType, error)
Fetch([]string) ([]*metricType, error)
GetVersions(core.Namespace) ([]*metricType, error)
Fetch(core.Namespace) ([]*metricType, error)
Item() (string, []*metricType)
Next() bool
Subscribe([]string, int) error
Unsubscribe([]string, int) error
GetPlugin([]string, int) (*loadedPlugin, error)
GetPlugin(core.Namespace, int) (*loadedPlugin, error)
}

type managesSigning interface {
Expand Down Expand Up @@ -449,7 +449,7 @@ func (p *pluginControl) SwapPlugins(in *core.RequestedPlugin, out core.Cataloged
}

// MatchQueryToNamespaces performs the process of matching the 'ns' with namespaces of all cataloged metrics
func (p *pluginControl) MatchQueryToNamespaces(ns []string) ([][]string, serror.SnapError) {
func (p *pluginControl) MatchQueryToNamespaces(ns core.Namespace) ([]core.Namespace, serror.SnapError) {
// carry out the matching process
nss, err := p.metricCatalog.MatchQuery(ns)
if err != nil {
Expand All @@ -460,7 +460,7 @@ func (p *pluginControl) MatchQueryToNamespaces(ns []string) ([][]string, serror.

// ExpandWildcards returns all matched metrics namespaces with given 'ns'
// as the results of matching query process which has been done
func (p *pluginControl) ExpandWildcards(ns []string) ([][]string, serror.SnapError) {
func (p *pluginControl) ExpandWildcards(ns core.Namespace) ([]core.Namespace, serror.SnapError) {
// retrieve queried namespaces
nss, err := p.metricCatalog.GetQueriedNamespaces(ns)
if err != nil {
Expand Down Expand Up @@ -846,12 +846,12 @@ func (p *pluginControl) AvailablePlugins() []core.AvailablePlugin {
// MetricCatalog returns the entire metric catalog
// NOTE: The returned data from this function should be considered constant and read only
func (p *pluginControl) MetricCatalog() ([]core.CatalogedMetric, error) {
return p.FetchMetrics([]string{}, 0)
return p.FetchMetrics(core.Namespace{}, 0)
}

// FetchMetrics returns the metrics which fall under the given namespace
// NOTE: The returned data from this function should be considered constant and read only
func (p *pluginControl) FetchMetrics(ns []string, version int) ([]core.CatalogedMetric, error) {
func (p *pluginControl) FetchMetrics(ns core.Namespace, version int) ([]core.CatalogedMetric, error) {
mts, err := p.metricCatalog.Fetch(ns)
if err != nil {
return nil, err
Expand All @@ -869,11 +869,11 @@ func (p *pluginControl) FetchMetrics(ns []string, version int) ([]core.Cataloged
return cmt, nil
}

func (p *pluginControl) GetMetric(ns []string, ver int) (core.CatalogedMetric, error) {
func (p *pluginControl) GetMetric(ns core.Namespace, ver int) (core.CatalogedMetric, error) {
return p.metricCatalog.Get(ns, ver)
}

func (p *pluginControl) GetMetricVersions(ns []string) ([]core.CatalogedMetric, error) {
func (p *pluginControl) GetMetricVersions(ns core.Namespace) ([]core.CatalogedMetric, error) {
mts, err := p.metricCatalog.GetVersions(ns)
if err != nil {
return nil, err
Expand All @@ -886,7 +886,7 @@ func (p *pluginControl) GetMetricVersions(ns []string) ([]core.CatalogedMetric,
return rmts, nil
}

func (p *pluginControl) MetricExists(mns []string, ver int) bool {
func (p *pluginControl) MetricExists(mns core.Namespace, ver int) bool {
_, err := p.metricCatalog.Get(mns, ver)
if err == nil {
return true
Expand Down Expand Up @@ -1068,7 +1068,7 @@ func groupMetricTypesByPlugin(cat catalogsMetrics, metricTypes []core.Metric) (m
}
lp := catalogedmt.Plugin
if lp == nil {
return nil, serror.New(errorMetricNotFound(incomingmt.Namespace()))
return nil, serror.New(errorMetricNotFound(incomingmt.Namespace().Strings()))
}
key := lp.Key()
pmt, _ := pmts[key]
Expand Down
Loading

0 comments on commit 10d107e

Please sign in to comment.