Documentation ¶
Index ¶
- type ClientCluster
- func (c *ClientCluster) Close()
- func (c *ClientCluster) Cmd(cmd string, args ...interface{}) *radix.Resp
- func (c *ClientCluster) GetAddrForKey(key string) string
- func (c *ClientCluster) GetEvery() (map[string]*radix.Client, error)
- func (c *ClientCluster) GetForKey(key string) (*radix.Client, error)
- func (c *ClientCluster) Put(conn *radix.Client)
- func (c *ClientCluster) Reset() error
- type ClusterSlotsNode
- type ClusterSlotsSlot
- type RedisServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientCluster ¶
type ClientCluster struct { Resps map[string]*radix.Resp Resp *radix.Resp Clients map[string]*radix.Client Client *radix.Client Addrs map[string]string Addr string Error error Servers map[string]*RedisServer Server *RedisServer }
ClientCluster struct used to simulate in unittest the clientCluster from radix
func NewClientCluster ¶
func NewClientCluster() *ClientCluster
NewClientCluster create a new ClientCluster structure and initialize all field to nil or empty map/strings
func (*ClientCluster) Close ¶
func (c *ClientCluster) Close()
Close calls Close on all connected clients. Once this is called no other methods should be called on this instance of Cluster
func (*ClientCluster) Cmd ¶
func (c *ClientCluster) Cmd(cmd string, args ...interface{}) *radix.Resp
Cmd performs the given command on the correct cluster node and gives back the command's reply. The command *must* have a key parameter (i.e. len(args) >= 1). If any MOVED or ASK errors are returned they will be transparently handled by this method.
func (*ClientCluster) GetAddrForKey ¶
func (c *ClientCluster) GetAddrForKey(key string) string
GetAddrForKey returns the address which would be used to handle the given key in the cluster.
func (*ClientCluster) GetEvery ¶
func (c *ClientCluster) GetEvery() (map[string]*radix.Client, error)
GetEvery returns a single *radix.Client per master that the cluster currently knows about. The map returned maps the address of the client to the client itself. If there is an error retrieving any of the clients (for instance if a new connection has to be made to get it) only that error is returned. Each client must be returned back to its pools using Put when through
func (*ClientCluster) GetForKey ¶
func (c *ClientCluster) GetForKey(key string) (*radix.Client, error)
GetForKey returns the Client which *ought* to handle the given key, based on Cluster's understanding of the cluster topology at the given moment. If the slot isn't known or there is an error contacting the correct node, a random client is returned. The client must be returned back to its pool using Put when through
func (*ClientCluster) Put ¶
func (c *ClientCluster) Put(conn *radix.Client)
Put putss the connection back in its pool. To be used alongside any of the Get* methods once use of the redis.Client is done
func (*ClientCluster) Reset ¶
func (c *ClientCluster) Reset() error
Reset will re-retrieve the cluster topology and set up/teardown connections as necessary.
type ClusterSlotsNode ¶
ClusterSlotsNode Representation of a node as returned by the CLUSTER SLOT command
type ClusterSlotsSlot ¶
type ClusterSlotsSlot struct { Min int Max int Nodes []ClusterSlotsNode }
ClusterSlotsSlot Representation of a slot as returned by the CLUSTER SLOT command
type RedisServer ¶
type RedisServer struct { sync.Mutex Ln net.Listener Responses map[string][]interface{} // contains filtered or unexported fields }
RedisServer Fake Redis Server struct
func NewRedisServer ¶
func NewRedisServer(t *testing.T) *RedisServer
NewRedisServer returns new Fake RedisServer instance
func (*RedisServer) GetHostPort ¶
func (r *RedisServer) GetHostPort() string
GetHostPort return the host port of redis server
func (*RedisServer) PushResponse ¶
func (r *RedisServer) PushResponse(rq string, response interface{})
PushResponse add a response to a specific request