updates for breaking changes in go-micro

This commit is contained in:
Asim Aslam 2019-12-16 15:41:04 +00:00 committed by Vasiliy Tolstov
parent 7bf60f879d
commit e64808d638

View File

@ -1,14 +1,13 @@
package redis package redis
import ( import (
"github.com/micro/go-micro/config/options"
"github.com/micro/go-micro/store" "github.com/micro/go-micro/store"
redis "gopkg.in/redis.v3" redis "gopkg.in/redis.v3"
) )
type rkv struct { type rkv struct {
options.Options options store.Options
Client *redis.Client Client *redis.Client
} }
func (r *rkv) Read(keys ...string) ([]*store.Record, error) { func (r *rkv) Read(keys ...string) ([]*store.Record, error) {
@ -85,21 +84,20 @@ func (r *rkv) String() string {
return "redis" return "redis"
} }
func NewStore(opts ...options.Option) store.Store { func NewStore(opts ...store.Option) store.Store {
options := options.NewOptions(opts...) var options store.Options
for _, o := range opts {
var nodes []string o(&options)
if n, ok := options.Values().Get("store.nodes"); ok {
nodes = n.([]string)
} }
nodes := options.Nodes
if len(nodes) == 0 { if len(nodes) == 0 {
nodes = []string{"127.0.0.1:6379"} nodes = []string{"127.0.0.1:6379"}
} }
return &rkv{ return &rkv{
Options: options, options: options,
Client: redis.NewClient(&redis.Options{ Client: redis.NewClient(&redis.Options{
Addr: nodes[0], Addr: nodes[0],
Password: "", // no password set Password: "", // no password set