Skip to content

Commit

Permalink
Merge pull request redis#822 from go-redis/fix/receive-message-rework
Browse files Browse the repository at this point in the history
Rework ReceiveMessage
  • Loading branch information
vmihailenco authored Jul 23, 2018
2 parents f7e97f0 + ea9da7c commit 77d7128
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 199 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Ring got new options called `HashReplicas` and `Hash`. It is recommended to set `HashReplicas = 1000` for better keys distribution between shards.
- Cluster client was optimized to use much less memory when reloading cluster state.
- ReceiveMessage is re-worked to not use ReceiveTimeout so it does not lose data when timeout occurres.

## v6.12

Expand Down
8 changes: 4 additions & 4 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,11 +1500,9 @@ func (c *ClusterClient) txPipelineReadQueued(
}

func (c *ClusterClient) pubSub(channels []string) *PubSub {
opt := c.opt.clientOptions()

var node *clusterNode
return &PubSub{
opt: opt,
pubsub := &PubSub{
opt: c.opt.clientOptions(),

newConn: func(channels []string) (*pool.Conn, error) {
if node == nil {
Expand All @@ -1527,6 +1525,8 @@ func (c *ClusterClient) pubSub(channels []string) *PubSub {
return node.Client.connPool.CloseConn(cn)
},
}
pubsub.init()
return pubsub
}

// Subscribe subscribes the client to the specified channels.
Expand Down
2 changes: 1 addition & 1 deletion cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ var _ = Describe("ClusterClient", func() {

ttl := cmds[(i*2)+1].(*redis.DurationCmd)
dur := time.Duration(i+1) * time.Hour
Expect(ttl.Val()).To(BeNumerically("~", dur, 10*time.Second))
Expect(ttl.Val()).To(BeNumerically("~", dur, 30*time.Second))
}
})

Expand Down
5 changes: 0 additions & 5 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package redis
import (
"fmt"
"net"
"time"

"github.com/go-redis/redis/internal/hashtag"
"github.com/go-redis/redis/internal/pool"
Expand All @@ -17,10 +16,6 @@ func (c *PubSub) SetNetConn(netConn net.Conn) {
c.cn = pool.NewConn(netConn)
}

func (c *PubSub) ReceiveMessageTimeout(timeout time.Duration) (*Message, error) {
return c.receiveMessage(timeout)
}

func (c *ClusterClient) LoadState() (*clusterState, error) {
return c.loadState()
}
Expand Down
Loading

0 comments on commit 77d7128

Please sign in to comment.