Newer
Older
package ubuntu
import (
"fmt"
"github.com/openconfig/gnmi/proto/gnmi"
)
type PathFunc func(path *gnmi.Path, val *gnmi.TypedValue) error
type PathMap map[string]PathFunc
func (pm PathMap) Register(s string, fn PathFunc) error {
if _, found := pm[s]; found {
return fmt.Errorf("a function is already registered for path: '%s'", s)
}
pm[s] = fn
return nil
}
func (pm PathMap) Execute(s string) error {
return execute(pm, s)
}
func execute(pm PathMap, p string) error {
if _, found := pm[p]; found {
//return fn()
}
return fmt.Errorf("The given path: '%s' is not supported", p)
}