updates for breaking changes in go-micro
This commit is contained in:
parent
7bf60f879d
commit
e64808d638
20
redis.go
20
redis.go
@ -1,14 +1,13 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/config/options"
|
||||
"github.com/micro/go-micro/store"
|
||||
redis "gopkg.in/redis.v3"
|
||||
)
|
||||
|
||||
type rkv struct {
|
||||
options.Options
|
||||
Client *redis.Client
|
||||
options store.Options
|
||||
Client *redis.Client
|
||||
}
|
||||
|
||||
func (r *rkv) Read(keys ...string) ([]*store.Record, error) {
|
||||
@ -85,21 +84,20 @@ func (r *rkv) String() string {
|
||||
return "redis"
|
||||
}
|
||||
|
||||
func NewStore(opts ...options.Option) store.Store {
|
||||
options := options.NewOptions(opts...)
|
||||
|
||||
var nodes []string
|
||||
|
||||
if n, ok := options.Values().Get("store.nodes"); ok {
|
||||
nodes = n.([]string)
|
||||
func NewStore(opts ...store.Option) store.Store {
|
||||
var options store.Options
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
nodes := options.Nodes
|
||||
|
||||
if len(nodes) == 0 {
|
||||
nodes = []string{"127.0.0.1:6379"}
|
||||
}
|
||||
|
||||
return &rkv{
|
||||
Options: options,
|
||||
options: options,
|
||||
Client: redis.NewClient(&redis.Options{
|
||||
Addr: nodes[0],
|
||||
Password: "", // no password set
|
||||
|
Loading…
Reference in New Issue
Block a user