2013-11-05 09:59:00 +00:00
|
|
|
package metastore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
//this is for testing only
|
|
|
|
|
|
|
|
type MetaStoreMemoryBacking struct {
|
2013-11-10 09:31:50 +00:00
|
|
|
m map[string]string
|
2013-11-05 09:59:00 +00:00
|
|
|
}
|
|
|
|
|
2013-11-10 09:31:50 +00:00
|
|
|
func NewMetaStoreMemoryBacking() *MetaStoreMemoryBacking {
|
|
|
|
mms := &MetaStoreMemoryBacking{}
|
|
|
|
mms.m = make(map[string]string)
|
2013-11-05 09:59:00 +00:00
|
|
|
return mms
|
|
|
|
}
|
|
|
|
|
2013-11-10 09:31:50 +00:00
|
|
|
func (mms MetaStoreMemoryBacking) Set(path, val string) error {
|
|
|
|
mms.m[path] = val
|
2013-11-05 09:59:00 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2013-11-10 09:31:50 +00:00
|
|
|
func (mms MetaStoreMemoryBacking) Get(path string) (val string, err error) {
|
2013-11-05 09:59:00 +00:00
|
|
|
var ok bool
|
2013-11-10 09:31:50 +00:00
|
|
|
val, ok = mms.m[path]
|
2013-11-05 09:59:00 +00:00
|
|
|
if !ok {
|
2013-11-10 09:31:50 +00:00
|
|
|
return "", fmt.Errorf("Missing value for %s", path)
|
2013-11-05 09:59:00 +00:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2013-11-10 09:31:50 +00:00
|
|
|
func (mms MetaStoreMemoryBacking) Has(path string) (ok bool) {
|
|
|
|
_, ok = mms.m[path]
|
2013-11-05 09:59:00 +00:00
|
|
|
return
|
|
|
|
}
|