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.
33 lines
599 B
33 lines
599 B
package metastore
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
)
|
|
|
|
type MetaStoreBacking interface {
|
|
Get(path string) (string, error)
|
|
Set(path, val string) error
|
|
Has(path string) bool
|
|
}
|
|
|
|
type MetaStore struct {
|
|
MetaStoreBacking
|
|
}
|
|
|
|
func (m *MetaStore) SetUint64(path string, val uint64) error {
|
|
return m.Set(path, strconv.FormatUint(val, 10))
|
|
}
|
|
|
|
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
|
|
} else {
|
|
if e != nil {
|
|
return 0, e
|
|
}
|
|
err = errors.New("Not found value for " + path)
|
|
}
|
|
return
|
|
}
|