cluster

package
v3.0.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	CreatePool func(host string, maxConn int, dialOption ...redis.DialOption) *redis.Pool
	// contains filtered or unexported fields
}

func (*Cluster) GetConnByAddr

func (c *Cluster) GetConnByAddr(addr string) (conn redis.Conn, isReadOnly bool, err error)

getConnFromAddr ...

func (*Cluster) GetMasterFromSlaveIP

func (c *Cluster) GetMasterFromSlaveIP(slaveIP string) (masterIP string, err error)

func (*Cluster) GetMasterIPs

func (c *Cluster) GetMasterIPs() (masterIPs []string)

func (*Cluster) GetNodeIPBySlot

func (c *Cluster) GetNodeIPBySlot(slot int, readOnly bool) (nodeIP string, err error)

func (*Cluster) GetSlaveIPs

func (c *Cluster) GetSlaveIPs() (slaveIPs []string)

func (*Cluster) HandleError

func (c *Cluster) HandleError(err error)

func (*Cluster) InitClusterRegistry

func (c *Cluster) InitClusterRegistry() (err error)

func (*Cluster) Slot

func (c *Cluster) Slot(key string) int

Slot returns the hash slot for the key.

func (*Cluster) Stats

func (c *Cluster) Stats() map[string]redis.PoolStats

Stats returns the current statistics for all pools. Keys are node's addresses.

type ClusterInterface

type ClusterInterface interface {
	GetMasterIPs() (masterIPs []string)
	GetMasterFromSlaveIP(slaveIP string) (masterIP string, err error)
	GetSlaveIPs() (slaveIPs []string)
	GetConnByAddr(addr string) (conn redis.Conn, isReadOnly bool, err error)
	GetNodeIPBySlot(slot int, readOnly bool) (nodeIP string, err error)

	Slot(key string) int
	HandleError(err error)
	// contains filtered or unexported methods
}

func New

func New(allIPs []string, maxConn int, createPool func(host string, maxConn int, dialOption ...redis.DialOption) *redis.Pool, dialOption ...redis.DialOption) ClusterInterface

type RedirError

type RedirError struct {
	// Type indicates if the redirection is a MOVED or an ASK.
	Type string
	// NewSlot is the slot number of the redirection.
	NewSlot int
	// Addr is the node address to redirect to.
	Addr string
	// contains filtered or unexported fields
}

func ParseRedir

func ParseRedir(err error) *RedirError

ParseRedir parses err into a RedirError. If err is not a MOVED or ASK error or if it is nil, it returns nil.

func (*RedirError) Error

func (e *RedirError) Error() string

Error returns the error message of a RedirError. This is the message as received from redis.

type SlotMap

type SlotMap struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL