move resolve into package
This commit is contained in:
9
mongo.go
9
mongo.go
@@ -3,6 +3,7 @@ package storage
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"local/storage/resolve"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -55,8 +56,8 @@ func NewMongo(addr string, auth ...string) (*Mongo, error) {
|
||||
}
|
||||
|
||||
func (mg *Mongo) List(ns []string, limits ...string) ([]string, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
limits = resolveLimits(limits)
|
||||
namespace := resolve.Namespace(ns)
|
||||
limits = resolve.Limits(limits)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
collection := mg.db.Database(DefaultNamespace).Collection(namespace)
|
||||
@@ -88,7 +89,7 @@ func (mg *Mongo) List(ns []string, limits ...string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (mg *Mongo) Get(key string, ns ...string) ([]byte, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
collection := mg.db.Database(DefaultNamespace).Collection(namespace)
|
||||
@@ -118,7 +119,7 @@ func (mg *Mongo) Get(key string, ns ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (mg *Mongo) Set(key string, value []byte, ns ...string) error {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
collection := mg.db.Database(DefaultNamespace).Collection(namespace)
|
||||
|
||||
Reference in New Issue
Block a user