change store options
This commit is contained in:
@@ -7,13 +7,12 @@ import (
|
||||
|
||||
client "github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/mvcc/mvccpb"
|
||||
"github.com/micro/go-micro/config/options"
|
||||
"github.com/micro/go-micro/store"
|
||||
)
|
||||
|
||||
type ekv struct {
|
||||
options.Options
|
||||
kv client.KV
|
||||
options store.Options
|
||||
kv client.KV
|
||||
}
|
||||
|
||||
func (e *ekv) Read(keys ...string) ([]*store.Record, error) {
|
||||
@@ -91,15 +90,15 @@ func (e *ekv) String() string {
|
||||
return "etcd"
|
||||
}
|
||||
|
||||
func NewStore(opts ...options.Option) store.Store {
|
||||
options := options.NewOptions(opts...)
|
||||
|
||||
var endpoints []string
|
||||
|
||||
if e, ok := options.Values().Get("store.nodes"); ok {
|
||||
endpoints = e.([]string)
|
||||
func NewStore(opts ...store.Option) store.Store {
|
||||
var options store.Options
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
// get the endpoints
|
||||
endpoints := options.Nodes
|
||||
|
||||
if len(endpoints) == 0 {
|
||||
endpoints = []string{"http://127.0.0.1:2379"}
|
||||
}
|
||||
@@ -113,7 +112,7 @@ func NewStore(opts ...options.Option) store.Store {
|
||||
}
|
||||
|
||||
return &ekv{
|
||||
Options: options,
|
||||
options: options,
|
||||
kv: client.NewKV(c),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user