@@ -10,7 +10,6 @@ import (
1010 "time"
1111
1212 "github.com/rueian/rueidis/internal/cmds"
13- "github.com/rueian/rueidis/internal/proto"
1413)
1514
1615var ErrNoSlot = errors .New ("the slot has no redis node" )
@@ -84,7 +83,7 @@ func (c *clusterClient) refresh() (err error) {
8483}
8584
8685func (c * clusterClient ) _refresh () (err error ) {
87- var reply proto. Message
86+ var reply RedisMessage
8887 var dead []string
8988
9089retry:
@@ -114,7 +113,7 @@ retry:
114113 return err
115114 }
116115
117- if len (reply .Values ) == 0 {
116+ if len (reply .values ) == 0 {
118117 if _ , err = c .init (); err != nil {
119118 return err
120119 }
@@ -177,20 +176,20 @@ type group struct {
177176 slots [][2 ]int64
178177}
179178
180- func parseSlots (slots proto. Message ) map [string ]group {
181- groups := make (map [string ]group , len (slots .Values ))
182- for _ , v := range slots .Values {
183- master := fmt .Sprintf ("%s:%d" , v .Values [2 ].Values [0 ].String , v .Values [2 ].Values [1 ].Integer )
179+ func parseSlots (slots RedisMessage ) map [string ]group {
180+ groups := make (map [string ]group , len (slots .values ))
181+ for _ , v := range slots .values {
182+ master := fmt .Sprintf ("%s:%d" , v .values [2 ].values [0 ].string , v .values [2 ].values [1 ].integer )
184183 g , ok := groups [master ]
185184 if ! ok {
186185 g .slots = make ([][2 ]int64 , 0 )
187- g .nodes = make ([]string , 0 , len (v .Values )- 2 )
188- for i := 2 ; i < len (v .Values ); i ++ {
189- dst := fmt .Sprintf ("%s:%d" , v .Values [i ].Values [0 ].String , v .Values [i ].Values [1 ].Integer )
186+ g .nodes = make ([]string , 0 , len (v .values )- 2 )
187+ for i := 2 ; i < len (v .values ); i ++ {
188+ dst := fmt .Sprintf ("%s:%d" , v .values [i ].values [0 ].string , v .values [i ].values [1 ].integer )
190189 g .nodes = append (g .nodes , dst )
191190 }
192191 }
193- g .slots = append (g .slots , [2 ]int64 {v .Values [0 ].Integer , v .Values [1 ].Integer })
192+ g .slots = append (g .slots , [2 ]int64 {v .values [0 ].integer , v .values [1 ].integer })
194193 groups [master ] = g
195194 }
196195 return groups
@@ -242,11 +241,11 @@ func (c *clusterClient) B() *cmds.Builder {
242241 return c .cmd
243242}
244243
245- func (c * clusterClient ) Do (ctx context.Context , cmd cmds.Completed ) (resp proto. Result ) {
244+ func (c * clusterClient ) Do (ctx context.Context , cmd cmds.Completed ) (resp RedisResult ) {
246245retry:
247246 cc , err := c .pick (cmd .Slot ())
248247 if err != nil {
249- resp = proto . NewErrResult (err )
248+ resp = newErrResult (err )
250249 goto ret
251250 }
252251 resp = cc .Do (cmd )
@@ -269,11 +268,11 @@ ret:
269268 return resp
270269}
271270
272- func (c * clusterClient ) DoCache (ctx context.Context , cmd cmds.Cacheable , ttl time.Duration ) (resp proto. Result ) {
271+ func (c * clusterClient ) DoCache (ctx context.Context , cmd cmds.Cacheable , ttl time.Duration ) (resp RedisResult ) {
273272retry:
274273 cc , err := c .pick (cmd .Slot ())
275274 if err != nil {
276- resp = proto . NewErrResult (err )
275+ resp = newErrResult (err )
277276 goto ret
278277 }
279278 resp = cc .DoCache (cmd , ttl )
@@ -355,18 +354,18 @@ func (c *dedicatedClusterClient) B() *cmds.Builder {
355354 return c .cmd
356355}
357356
358- func (c * dedicatedClusterClient ) Do (ctx context.Context , cmd cmds.Completed ) (resp proto. Result ) {
357+ func (c * dedicatedClusterClient ) Do (ctx context.Context , cmd cmds.Completed ) (resp RedisResult ) {
359358 c .check (cmd .Slot ())
360359 if err := c .acquire (); err != nil {
361- return proto . NewErrResult (err )
360+ return newErrResult (err )
362361 } else {
363362 resp = c .wire .Do (cmd )
364363 }
365364 c .cmd .Put (cmd .CommandSlice ())
366365 return resp
367366}
368367
369- func (c * dedicatedClusterClient ) DoMulti (ctx context.Context , multi ... cmds.Completed ) (resp []proto. Result ) {
368+ func (c * dedicatedClusterClient ) DoMulti (ctx context.Context , multi ... cmds.Completed ) (resp []RedisResult ) {
370369 if len (multi ) == 0 {
371370 return nil
372371 }
@@ -376,9 +375,9 @@ func (c *dedicatedClusterClient) DoMulti(ctx context.Context, multi ...cmds.Comp
376375 if err := c .acquire (); err == nil {
377376 resp = c .wire .DoMulti (multi ... )
378377 } else {
379- resp = make ([]proto. Result , len (multi ))
378+ resp = make ([]RedisResult , len (multi ))
380379 for i := range resp {
381- resp [i ] = proto . NewErrResult (err )
380+ resp [i ] = newErrResult (err )
382381 }
383382 }
384383 for _ , cmd := range multi {
0 commit comments