1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Faster and simpler pool.

This commit is contained in:
Vladimir Mihailenco
2016-03-17 18:00:47 +02:00
parent 93a7fe0de3
commit 6e1aef39ea
22 changed files with 418 additions and 492 deletions

View File

@ -68,7 +68,7 @@ var _ = Describe("PubSub", func() {
Expect(subscr.Count).To(Equal(0))
}
stats := client.Pool().Stats()
stats := client.PoolStats()
Expect(stats.Requests - stats.Hits - stats.Waits).To(Equal(uint32(2)))
})
@ -195,7 +195,7 @@ var _ = Describe("PubSub", func() {
Expect(subscr.Count).To(Equal(0))
}
stats := client.Pool().Stats()
stats := client.PoolStats()
Expect(stats.Requests - stats.Hits - stats.Waits).To(Equal(uint32(2)))
})
@ -256,6 +256,9 @@ var _ = Describe("PubSub", func() {
})
It("should ReceiveMessage after timeout", func() {
timeout := time.Second
redis.SetReceiveMessageTimeout(timeout)
pubsub, err := client.Subscribe("mychannel")
Expect(err).NotTo(HaveOccurred())
defer pubsub.Close()
@ -267,7 +270,7 @@ var _ = Describe("PubSub", func() {
done <- true
}()
time.Sleep(5*time.Second + 100*time.Millisecond)
time.Sleep(timeout + 100*time.Millisecond)
n, err := client.Publish("mychannel", "hello").Result()
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(1)))
@ -280,8 +283,9 @@ var _ = Describe("PubSub", func() {
Eventually(done).Should(Receive())
stats := client.Pool().Stats()
Expect(stats.Requests - stats.Hits - stats.Waits).To(Equal(uint32(2)))
stats := client.PoolStats()
Expect(stats.Requests).To(Equal(uint32(3)))
Expect(stats.Hits).To(Equal(uint32(1)))
})
expectReceiveMessageOnError := func(pubsub *redis.PubSub) {
@ -311,8 +315,9 @@ var _ = Describe("PubSub", func() {
Eventually(done).Should(Receive())
stats := client.Pool().Stats()
Expect(stats.Requests - stats.Hits - stats.Waits).To(Equal(uint32(2)))
stats := client.PoolStats()
Expect(stats.Requests).To(Equal(uint32(4)))
Expect(stats.Hits).To(Equal(uint32(1)))
}
It("Subscribe should reconnect on ReceiveMessage error", func() {