move resolve into package

This commit is contained in:
Bel LaPointe
2021-02-21 12:39:15 -06:00
parent ff8b908ee7
commit 7f2d451ca4
15 changed files with 205 additions and 175 deletions

9
map.go
View File

@@ -2,6 +2,7 @@ package storage
import (
"fmt"
"local/storage/resolve"
"sync"
)
@@ -40,8 +41,8 @@ func (m *Map) Close() error {
func (m *Map) List(ns []string, limits ...string) ([]string, error) {
m.lock.RLock()
defer m.lock.RUnlock()
namespace := resolveNamespace(ns)
limits = resolveLimits(limits)
namespace := resolve.Namespace(ns)
limits = resolve.Limits(limits)
keys := []string{}
if _, ok := m.m[namespace]; !ok {
@@ -59,7 +60,7 @@ func (m *Map) List(ns []string, limits ...string) ([]string, error) {
func (m *Map) Get(key string, ns ...string) ([]byte, error) {
m.lock.RLock()
defer m.lock.RUnlock()
namespace := resolveNamespace(ns)
namespace := resolve.Namespace(ns)
if _, ok := m.m[namespace]; !ok {
return nil, ErrNotFound
}
@@ -72,7 +73,7 @@ func (m *Map) Get(key string, ns ...string) ([]byte, error) {
func (m *Map) Set(key string, value []byte, ns ...string) error {
m.lock.Lock()
defer m.lock.Unlock()
namespace := resolveNamespace(ns)
namespace := resolve.Namespace(ns)
if value == nil {
if _, ok := m.m[namespace]; !ok {
return nil