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

  1. package metastore
  2. import (
  3. "errors"
  4. "strconv"
  5. )
  6. type MetaStoreBacking interface {
  7. Get(path string) (string, error)
  8. Set(path, val string) error
  9. Has(path string) bool
  10. }
  11. type MetaStore struct {
  12. MetaStoreBacking
  13. }
  14. func (m *MetaStore) SetUint64(path string, val uint64) error {
  15. return m.Set(path, strconv.FormatUint(val, 10))
  16. }
  17. func (m *MetaStore) GetUint64(path string) (val uint64, err error) {
  18. if b, e := m.Get(path); e == nil {
  19. val, err = strconv.ParseUint(b, 10, 64)
  20. return
  21. } else {
  22. if e != nil {
  23. return 0, e
  24. }
  25. err = errors.New("Not found value for " + path)
  26. }
  27. return
  28. }