1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Simplify connection management with sticky connection pool. Fixes #260.

This commit is contained in:
Vladimir Mihailenco
2016-03-01 12:31:06 +02:00
parent 0382d1e980
commit 110e93a8e4
10 changed files with 140 additions and 90 deletions

View File

@ -166,4 +166,31 @@ var _ = Describe("Multi", func() {
})
Expect(err).NotTo(HaveOccurred())
})
It("should recover from bad connection when there are no commands", func() {
// Put bad connection in the pool.
cn, _, err := client.Pool().Get()
Expect(err).NotTo(HaveOccurred())
cn.SetNetConn(&badConn{})
err = client.Pool().Put(cn)
Expect(err).NotTo(HaveOccurred())
{
tx, err := client.Watch("key")
Expect(err).To(MatchError("bad connection"))
Expect(tx).To(BeNil())
}
{
tx, err := client.Watch("key")
Expect(err).NotTo(HaveOccurred())
err = tx.Ping().Err()
Expect(err).NotTo(HaveOccurred())
err = tx.Close()
Expect(err).NotTo(HaveOccurred())
}
})
})