summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-redis/redis/export_test.go
blob: b88e41be9eb0c89524e4319c0c647553bbb09cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package redis

import (
	"net"
	"time"

	"github.com/go-redis/redis/internal/pool"
)

func (c *baseClient) Pool() pool.Pooler {
	return c.connPool
}

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) SlotAddrs(slot int) []string {
	var addrs []string
	for _, n := range c.state().slotNodes(slot) {
		addrs = append(addrs, n.Client.getAddr())
	}
	return addrs
}

// SwapSlot swaps a slot's master/slave address for testing MOVED redirects.
func (c *ClusterClient) SwapSlotNodes(slot int) []string {
	nodes := c.state().slots[slot]
	nodes[0], nodes[1] = nodes[1], nodes[0]
	return c.SlotAddrs(slot)
}