You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
730 B
37 lines
730 B
package metastore
|
|
|
|
import (
|
|
"fmt"
|
|
"path"
|
|
)
|
|
|
|
//this is for testing only
|
|
|
|
type MetaStoreMemoryBacking struct {
|
|
m map[string][]byte
|
|
}
|
|
|
|
func NewMetaStoreMemoryBacking() MetaStoreMemoryBacking {
|
|
mms := MetaStoreMemoryBacking{}
|
|
mms.m = make(map[string][]byte)
|
|
return mms
|
|
}
|
|
|
|
func (mms MetaStoreMemoryBacking) Set(val []byte, elem ...string) error {
|
|
mms.m[path.Join(elem...)] = val
|
|
return nil
|
|
}
|
|
|
|
func (mms MetaStoreMemoryBacking) Get(elem ...string) (val []byte, err error) {
|
|
var ok bool
|
|
val, ok = mms.m[path.Join(elem...)]
|
|
if !ok {
|
|
return nil, fmt.Errorf("Missing value for %s", path.Join(elem...))
|
|
}
|
|
return
|
|
}
|
|
|
|
func (mms MetaStoreMemoryBacking) Has(elem ...string) (ok bool) {
|
|
_, ok = mms.m[path.Join(elem...)]
|
|
return
|
|
}
|