move options to dedicated package
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -2,14 +2,9 @@ package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// LogfFunc function used for Logf method
|
||||
// type LogfFunc func(ctx context.Context, level Level, msg string, args ...interface{})
|
||||
// type Wrapper interface {
|
||||
// Logf logs message with needed level
|
||||
// Logf(LogfFunc) LogfFunc
|
||||
// }
|
||||
"go.unistack.org/micro/v4/options"
|
||||
)
|
||||
|
||||
// NamespaceStore wrap store with namespace
|
||||
type NamespaceStore struct {
|
||||
@@ -23,7 +18,7 @@ func NewNamespaceStore(s Store, ns string) Store {
|
||||
return &NamespaceStore{s: s, ns: ns}
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Init(opts ...Option) error {
|
||||
func (w *NamespaceStore) Init(opts ...options.Option) error {
|
||||
return w.s.Init(opts...)
|
||||
}
|
||||
|
||||
@@ -35,24 +30,24 @@ func (w *NamespaceStore) Disconnect(ctx context.Context) error {
|
||||
return w.s.Disconnect(ctx)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Read(ctx context.Context, key string, val interface{}, opts ...ReadOption) error {
|
||||
return w.s.Read(ctx, key, val, append(opts, ReadNamespace(w.ns))...)
|
||||
func (w *NamespaceStore) Read(ctx context.Context, key string, val interface{}, opts ...options.Option) error {
|
||||
return w.s.Read(ctx, key, val, append(opts, options.Namespace(w.ns))...)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Write(ctx context.Context, key string, val interface{}, opts ...WriteOption) error {
|
||||
return w.s.Write(ctx, key, val, append(opts, WriteNamespace(w.ns))...)
|
||||
func (w *NamespaceStore) Write(ctx context.Context, key string, val interface{}, opts ...options.Option) error {
|
||||
return w.s.Write(ctx, key, val, append(opts, options.Namespace(w.ns))...)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Delete(ctx context.Context, key string, opts ...DeleteOption) error {
|
||||
return w.s.Delete(ctx, key, append(opts, DeleteNamespace(w.ns))...)
|
||||
func (w *NamespaceStore) Delete(ctx context.Context, key string, opts ...options.Option) error {
|
||||
return w.s.Delete(ctx, key, append(opts, options.Namespace(w.ns))...)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Exists(ctx context.Context, key string, opts ...ExistsOption) error {
|
||||
return w.s.Exists(ctx, key, append(opts, ExistsNamespace(w.ns))...)
|
||||
func (w *NamespaceStore) Exists(ctx context.Context, key string, opts ...options.Option) error {
|
||||
return w.s.Exists(ctx, key, append(opts, options.Namespace(w.ns))...)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) List(ctx context.Context, opts ...ListOption) ([]string, error) {
|
||||
return w.s.List(ctx, append(opts, ListNamespace(w.ns))...)
|
||||
func (w *NamespaceStore) List(ctx context.Context, opts ...options.Option) ([]string, error) {
|
||||
return w.s.List(ctx, append(opts, options.Namespace(w.ns))...)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Options() Options {
|
||||
@@ -66,17 +61,3 @@ func (w *NamespaceStore) Name() string {
|
||||
func (w *NamespaceStore) String() string {
|
||||
return w.s.String()
|
||||
}
|
||||
|
||||
// type NamespaceWrapper struct{}
|
||||
|
||||
// func NewNamespaceWrapper() Wrapper {
|
||||
// return &NamespaceWrapper{}
|
||||
// }
|
||||
|
||||
/*
|
||||
func (w *OmitWrapper) Logf(fn LogfFunc) LogfFunc {
|
||||
return func(ctx context.Context, level Level, msg string, args ...interface{}) {
|
||||
fn(ctx, level, msg, getArgs(args)...)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user