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:
@ -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())
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user