Documentation ¶
Index ¶
- Constants
- Variables
- func AuthPassword(c net.Conn, auth_type, passwd string)
- func Bytes2String(b []byte) string
- func CheckHandleNetError(err error) bool
- func CheckVersionChecksum(d []byte) (uint, uint64, error)
- func CompareVersion(a, b string, level int) int
- func CutRedisInfoSegment(content []byte, field string) []byte
- func Float64ToByte(float float64) string
- func FlushWriter(w *bufio.Writer)
- func GetAllClusterNode(client redigo.Conn, role string, choose string) ([]string, error)
- func GetFakeSlaveOffset(c redigo.Conn) (string, error)
- func GetLocalIp(preferdInterfaces []string) (ip string, interfaceName string, err error)
- func GetMetric(input int64) string
- func GetRDBChecksum(target, authType, auth string, tlsEnable bool) (string, error)
- func GetReadableRedisAddressThroughSentinel(sentinelAddrs []string, sentinelMasterName string, fromMaster bool) (string, error)
- func GetRedisVersion(target, authType, auth string, tlsEnable bool) (string, error)
- func GetTotalLink() int
- func GetWritableRedisAddressThroughSentinel(sentinelAddrs []string, sentinelMasterName string) (string, error)
- func Goodbye()
- func InitHttpApi(port int)
- func Iocopy(r io.Reader, w io.Writer, p []byte, max int) int
- func KeyToSlot(key string) uint16
- func NewClusterConn(clusterClient *redigoCluster.Cluster, recvChanSize int) redigo.Conn
- func NewRDBLoader(reader *bufio.Reader, rbytes *atomic2.Int64, size int) chan *rdb.BinEntry
- func OpenNetConn(target, auth_type, passwd string, tlsEnable bool) net.Conn
- func OpenNetConnSoft(target, auth_type, passwd string, tlsEnable bool) net.Conn
- func OpenReadFile(name string) (*os.File, int64)
- func OpenReadWriteFile(name string) *os.File
- func OpenRedisConn(target []string, auth_type, passwd string, isCluster bool, tlsEnable bool) redigo.Conn
- func OpenRedisConnWithTimeout(target []string, auth_type, passwd string, ...) redigo.Conn
- func OpenSyncConn(target string, auth_type, passwd string, tlsEnable bool) (net.Conn, <-chan int64)
- func OpenWriteFile(name string) *os.File
- func ParseAddress(tp string) error
- func ParseInfo(content []byte) map[string]string
- func ParseKeyspace(content []byte) (map[int32]int64, error)
- func ParseRedisInfo(content []byte) map[string]string
- func PickTargetRoundRobin(n int) int
- func ReadRESPEnd(c net.Conn) (string, error)
- func RemoveRESPEnd(input string) string
- func RestoreBigkey(client redigo.Conn, key string, value string, pttl int64, db int, preDb *int)
- func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry)
- func SelectDB(c redigo.Conn, db uint32)
- func SendPSyncAck(bw *bufio.Writer, offset int64) error
- func SendPSyncContinue(br *bufio.Reader, bw *bufio.Writer, runid string, offset int64)
- func SendPSyncFullsync(br *bufio.Reader, bw *bufio.Writer) (string, int64, <-chan int64)
- func SendPSyncListeningPort(c net.Conn, port int)
- func StartQoS(limit int) chan struct{}
- func String2Bytes(s string) []byte
- func Welcome()
- func WritePid(id string) (err error)
- func WritePidById(id string, path string) error
- type ClusterConn
- func (cc *ClusterConn) Close() error
- func (cc *ClusterConn) Do(commandName string, args ...interface{}) (reply interface{}, err error)
- func (cc *ClusterConn) Err() error
- func (cc *ClusterConn) Flush() error
- func (cc *ClusterConn) Receive() (reply interface{}, err error)
- func (cc *ClusterConn) Send(commandName string, args ...interface{}) error
- type ClusterNodeInfo
Constants ¶
const ( ReplayString = "string" ReplayInt64s = "int64s" )
const ( GolangSecurityTime = "2006-01-02T15:04:05Z" // GolangSecurityTime = "2006-01-02 15:04:05" ReaderBufferSize = bytesize.MB * 32 WriterBufferSize = bytesize.MB * 8 LogLevelNone = "none" LogLevelError = "error" LogLevelWarn = "warn" LogLevelInfo = "info" LogLevelDebug = "debug" LogLevelAll = "all" TencentCluster = "tencent_cluster" AliyunCluster = "aliyun_cluster" UCloudCluster = "ucloud_cluster" CodisCluster = "codis_cluster" CoidsErrMsg = "ERR backend server 'server' not found" )
const ( KB = 1024 MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB PB = 1024 * TB )
const ( AddressSplitter = "@" AddressHeaderSplitter = ":" AddressClusterSplitter = ";" )
Variables ¶
var ( Version = "$" LogRotater *logRotate.Logger StartTime string TargetRoundRobin int RDBVersion uint = 9 // 9 for 5.0 )
var (
HttpApi *nimo.HttpRestProvider
)
var (
RecvChanSize = 4096
)
Functions ¶
func AuthPassword ¶
func Bytes2String ¶
func CheckHandleNetError ¶
func CompareVersion ¶
* compare the version with given level. e.g., * 2.0.1, 2.0.3, level = 2 => equal: 0 * 2.0.1, 2.0.3, level = 3 => smaller: 1 * 3.1.1, 2.1 level = 2 => bigger: 2 * 3, 3.2, level = 2 => smaller: 1 * 3.a, 3.2, level = 2 => unknown: 3
func CutRedisInfoSegment ¶
cut segment
func Float64ToByte ¶
func FlushWriter ¶
func GetAllClusterNode ¶
return id list if choose == "id", otherwise address
func GetLocalIp ¶
func GetRDBChecksum ¶
func GetReadableRedisAddressThroughSentinel ¶
func GetReadableRedisAddressThroughSentinel(sentinelAddrs []string, sentinelMasterName string, fromMaster bool) (string, error)
GetReadableRedisAddressThroughSentinel gets readable redis address First, the function will pick one from available slaves randomly. If there is no available slave, it will pick master.
func GetRedisVersion ¶
func GetTotalLink ¶
func GetTotalLink() int
func GetWritableRedisAddressThroughSentinel ¶
func GetWritableRedisAddressThroughSentinel(sentinelAddrs []string, sentinelMasterName string) (string, error)
getWritableRedisAddressThroughSentinel gets writable redis address The function will return redis master address.
func InitHttpApi ¶
func InitHttpApi(port int)
func NewClusterConn ¶
func NewClusterConn(clusterClient *redigoCluster.Cluster, recvChanSize int) redigo.Conn
func NewRDBLoader ¶
func OpenNetConnSoft ¶
func OpenReadWriteFile ¶
func OpenRedisConn ¶
func OpenSyncConn ¶
func OpenWriteFile ¶
func ParseRedisInfo ¶
parse single info field: "info server", "info keyspace"
func PickTargetRoundRobin ¶
func ReadRESPEnd ¶
read until hit the end of RESP: "\r\n"
func RemoveRESPEnd ¶
func RestoreBigkey ¶
func SendPSyncContinue ¶
func SendPSyncFullsync ¶
func SendPSyncListeningPort ¶
func String2Bytes ¶
func WritePidById ¶
Types ¶
type ClusterConn ¶
type ClusterConn struct {
// contains filtered or unexported fields
}
implement redigo.Conn(https://github.com/garyburd/redigo) * Embed redis-go-cluster(https://github.com/chasex/redis-go-cluster) * The reason I create this struct is that redis-go-cluster isn't fulfill redigo.Conn * interface. So I implement "Err", "Send", "Flush" and "Receive" interfaces.
func (*ClusterConn) Close ¶
func (cc *ClusterConn) Close() error
func (*ClusterConn) Do ¶
func (cc *ClusterConn) Do(commandName string, args ...interface{}) (reply interface{}, err error)
func (*ClusterConn) Err ¶
func (cc *ClusterConn) Err() error
func (*ClusterConn) Flush ¶
func (cc *ClusterConn) Flush() error
send batcher and put the return into recvChan
func (*ClusterConn) Receive ¶
func (cc *ClusterConn) Receive() (reply interface{}, err error)
read recvChan
func (*ClusterConn) Send ¶
func (cc *ClusterConn) Send(commandName string, args ...interface{}) error
just add into batcher
type ClusterNodeInfo ¶
type ClusterNodeInfo struct { Id string Address string Flags string Master string PingSent string PongRecv string ConfigEpoch string LinkStat string Slot string }
func ClusterNodeChoose ¶
func ClusterNodeChoose(input []*ClusterNodeInfo, role string) []*ClusterNodeInfo
needMaster: true(master), false(slave)
func ParseClusterNode ¶
func ParseClusterNode(content []byte) []*ClusterNodeInfo
* 10.1.1.1:21331> cluster nodes * d49a4c7b516b8da222d46a0a589b77f381285977 10.1.1.1:21333@31333 master - 0 1557996786000 3 connected 10923-16383 * f23ba7be501b2dcd4d6eeabd2d25551513e5c186 10.1.1.1:21336@31336 slave d49a4c7b516b8da222d46a0a589b77f381285977 0 1557996785000 6 connected * 75fffcd521738606a919607a7ddd52bcd6d65aa8 10.1.1.1:21331@31331 myself,master - 0 1557996784000 1 connected 0-5460 * da3dd51bb9cb5803d99942e0f875bc5f36dc3d10 10.1.1.1:21332@31332 master - 0 1557996786260 2 connected 5461-10922 * eff4e654d3cc361a8ec63640812e394a8deac3d6 10.1.1.1:21335@31335 slave da3dd51bb9cb5803d99942e0f875bc5f36dc3d10 0 1557996787261 5 connected * 486e081f8d47968df6a7e43ef9d3ba93b77d03b2 10.1.1.1:21334@31334 slave 75fffcd521738606a919607a7ddd52bcd6d65aa8 0 1557996785258 4 connected