File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,8 @@ func (c *Ring) generalProcessPipeline(
798798 }
799799
800800 var wg sync.WaitGroup
801+ errs := make (chan error , len (cmdsMap ))
802+
801803 for hash , cmds := range cmdsMap {
802804 wg .Add (1 )
803805 go func (hash string , cmds []Cmder ) {
@@ -810,16 +812,24 @@ func (c *Ring) generalProcessPipeline(
810812 return
811813 }
812814
815+ hook := shard .Client .processPipelineHook
813816 if tx {
814817 cmds = wrapMultiExec (ctx , cmds )
815- _ = shard .Client .processTxPipelineHook (ctx , cmds )
816- } else {
817- _ = shard .Client .processPipelineHook (ctx , cmds )
818+ hook = shard .Client .processTxPipelineHook
819+ }
820+
821+ if err = hook (ctx , cmds ); err != nil {
822+ errs <- err
818823 }
819824 }(hash , cmds )
820825 }
821826
822827 wg .Wait ()
828+ close (errs )
829+
830+ if err := <- errs ; err != nil {
831+ return err
832+ }
823833 return cmdsFirstErr (cmds )
824834}
825835
Original file line number Diff line number Diff line change @@ -277,6 +277,21 @@ var _ = Describe("Redis Ring", func() {
277277 Expect (ringShard1 .Info (ctx ).Val ()).ToNot (ContainSubstring ("keys=" ))
278278 Expect (ringShard2 .Info (ctx ).Val ()).To (ContainSubstring ("keys=100" ))
279279 })
280+
281+ It ("return dial timeout error" , func () {
282+ opt := redisRingOptions ()
283+ opt .DialTimeout = 250 * time .Millisecond
284+ opt .Addrs = map [string ]string {"ringShardNotExist" : ":1997" }
285+ ring = redis .NewRing (opt )
286+
287+ _ , err := ring .Pipelined (ctx , func (pipe redis.Pipeliner ) error {
288+ pipe .HSet (ctx , "key" , "value" )
289+ pipe .Expire (ctx , "key" , time .Minute )
290+ return nil
291+ })
292+
293+ Expect (err ).To (HaveOccurred ())
294+ })
280295 })
281296
282297 Describe ("new client callback" , func () {
You can’t perform that action at this time.
0 commit comments