change store options
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/config/options"
|
||||
"context"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
@@ -11,20 +11,30 @@ type Options struct {
|
||||
Namespace string
|
||||
// Prefix of the keys used
|
||||
Prefix string
|
||||
// Alternative options
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
// Nodes is a list of nodes used to back the store
|
||||
func Nodes(a ...string) options.Option {
|
||||
return options.WithValue("store.nodes", a)
|
||||
func Nodes(a ...string) Option {
|
||||
return func(o *Options) {
|
||||
o.Nodes = a
|
||||
}
|
||||
}
|
||||
|
||||
// Prefix sets a prefix to any key ids used
|
||||
func Prefix(p string) options.Option {
|
||||
return options.WithValue("store.prefix", p)
|
||||
func Prefix(p string) Option {
|
||||
return func(o *Options) {
|
||||
o.Prefix = p
|
||||
}
|
||||
}
|
||||
|
||||
// Namespace offers a way to have multiple isolated
|
||||
// stores in the same backend, if supported.
|
||||
func Namespace(n string) options.Option {
|
||||
return options.WithValue("store.namespace", n)
|
||||
func Namespace(ns string) Option {
|
||||
return func(o *Options) {
|
||||
o.Namespace = ns
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user