forked from mirror/redis
Merge pull request #649 from go-redis/fix/receive-big-message
Add test for receive big message payload
This commit is contained in:
commit
9c20773cb2
|
@ -214,6 +214,7 @@ type Cmdable interface {
|
|||
ScriptKill() *StatusCmd
|
||||
ScriptLoad(script string) *StringCmd
|
||||
DebugObject(key string) *StringCmd
|
||||
Publish(channel string, message interface{}) *IntCmd
|
||||
PubSubChannels(pattern string) *StringSliceCmd
|
||||
PubSubNumSub(channels ...string) *StringIntMapCmd
|
||||
PubSubNumPat() *IntCmd
|
||||
|
@ -1880,8 +1881,8 @@ func (c *cmdable) DebugObject(key string) *StringCmd {
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
// Publish posts the message to the channel.
|
||||
func (c *cmdable) Publish(channel, message string) *IntCmd {
|
||||
cmd := NewIntCmd("PUBLISH", channel, message)
|
||||
func (c *cmdable) Publish(channel string, message interface{}) *IntCmd {
|
||||
cmd := NewIntCmd("publish", channel, message)
|
||||
c.process(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -424,4 +424,20 @@ var _ = Describe("PubSub", func() {
|
|||
|
||||
wg.Wait()
|
||||
})
|
||||
|
||||
It("handles big message payload", func() {
|
||||
pubsub := client.Subscribe("mychannel")
|
||||
defer pubsub.Close()
|
||||
|
||||
ch := pubsub.Channel()
|
||||
|
||||
bigVal := bigVal()
|
||||
err := client.Publish("mychannel", bigVal).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var msg *redis.Message
|
||||
Eventually(ch).Should(Receive(&msg))
|
||||
Expect(msg.Channel).To(Equal("mychannel"))
|
||||
Expect(msg.Payload).To(Equal(string(bigVal)))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -105,7 +105,7 @@ var _ = Describe("races", func() {
|
|||
It("should handle big vals in Get", func() {
|
||||
C, N = 4, 100
|
||||
|
||||
bigVal := bytes.Repeat([]byte{'*'}, 1<<17) // 128kb
|
||||
bigVal := bigVal()
|
||||
|
||||
err := client.Set("key", bigVal, 0).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -126,8 +126,7 @@ var _ = Describe("races", func() {
|
|||
It("should handle big vals in Set", func() {
|
||||
C, N = 4, 100
|
||||
|
||||
bigVal := bytes.Repeat([]byte{'*'}, 1<<17) // 128kb
|
||||
|
||||
bigVal := bigVal()
|
||||
perform(C, func(id int) {
|
||||
for i := 0; i < N; i++ {
|
||||
err := client.Set("key", bigVal, 0).Err()
|
||||
|
@ -245,3 +244,7 @@ var _ = Describe("races", func() {
|
|||
Expect(n).To(Equal(int64(N)))
|
||||
})
|
||||
})
|
||||
|
||||
func bigVal() []byte {
|
||||
return bytes.Repeat([]byte{'*'}, 1<<17) // 128kb
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue