2013-11-05 09:59:00 +00:00
|
|
|
package metastore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2013-11-10 09:31:50 +00:00
|
|
|
"strconv"
|
2013-11-05 09:59:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MetaStoreBacking interface {
|
2013-11-10 09:31:50 +00:00
|
|
|
Get(path string) (string, error)
|
|
|
|
Set(path, val string) error
|
|
|
|
Has(path string) bool
|
2013-11-05 09:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type MetaStore struct {
|
|
|
|
MetaStoreBacking
|
|
|
|
}
|
|
|
|
|
2013-11-10 09:31:50 +00:00
|
|
|
func (m *MetaStore) SetUint64(path string, val uint64) error {
|
|
|
|
return m.Set(path, strconv.FormatUint(val, 10))
|
2013-11-05 09:59:00 +00:00
|
|
|
}
|
|
|
|
|
2013-11-10 09:31:50 +00:00
|
|
|
func (m *MetaStore) GetUint64(path string) (val uint64, err error) {
|
|
|
|
if b, e := m.Get(path); e == nil {
|
|
|
|
val, err = strconv.ParseUint(b, 10, 64)
|
|
|
|
return
|
2013-11-05 09:59:00 +00:00
|
|
|
} else {
|
|
|
|
if e != nil {
|
|
|
|
return 0, e
|
|
|
|
}
|
2013-11-10 09:31:50 +00:00
|
|
|
err = errors.New("Not found value for " + path)
|
2013-11-05 09:59:00 +00:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|