Skip to content

Commit

Permalink
ring: return an error in pipeline when all shards are down.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jul 13, 2015
1 parent 7baacea commit 54dcf59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ func (pipe *RingPipeline) Exec() (cmds []Cmder, retErr error) {
name := pipe.ring.hash.Get(hashKey(cmd.clusterKey()))
if name == "" {
cmd.setErr(errRingShardsDown)
if retErr == nil {
retErr = errRingShardsDown
}
continue
}
cmdsMap[name] = append(cmdsMap[name], cmd)
Expand Down
9 changes: 9 additions & 0 deletions ring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ var _ = Describe("Redis ring", func() {
})

Describe("pipelining", func() {
It("returns an error when all shards are down", func() {
ring := redis.NewRing(&redis.RingOptions{})
_, err := ring.Pipelined(func(pipe *redis.RingPipeline) error {
pipe.Ping()
return nil
})
Expect(err).To(MatchError("redis: all ring shards are down"))
})

It("uses both shards", func() {
pipe := ring.Pipeline()
for i := 0; i < 100; i++ {
Expand Down

0 comments on commit 54dcf59

Please sign in to comment.