change store options

This commit is contained in:
Asim Aslam
2019-12-16 14:38:51 +00:00
parent e8e112144f
commit 59751c02e6
8 changed files with 156 additions and 179 deletions

View File

@@ -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),
}
}