add metastore, switching sequence to use it
metastore is for storing metadata. This will be used later when moving to distributed master mode.
This commit is contained in:
37
go/metastore/memory_backing.go
Normal file
37
go/metastore/memory_backing.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user