utils

package
v0.0.0-...-90f6a64 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: GPL-3.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAddr       = errors.New("invalid addr")
	ErrStopMigrateByUser = errors.New("migration stopped by user")
)

Functions

func DialTo

func DialTo(addr string, passwd string) (redis.Conn, error)

func DialToTimeout

func DialToTimeout(addr string, passwd string, readTimeout, writeTimeout time.Duration) (redis.Conn, error)

连接redis,返回连接

func GetExecutorPath

func GetExecutorPath() string

func GetRedisConfig

func GetRedisConfig(addr, passwd string, configName string) (string, error)

func GetRedisStat

func GetRedisStat(addr, passwd string) (map[string]string, error)

func GetZkLock

func GetZkLock(zkConn zkhelper.Conn, productName string) zkhelper.ZLocker

获取zk锁

func InitConfig

func InitConfig() (*cfg.Cfg, error)

func SlaveNoOne

func SlaveNoOne(addr, passwd string) error

向redis-server发送 SLAVEOF NO ONE 命令

func SlaveOf

func SlaveOf(slave, passwd string, master string) error

向redis-server发送 SLAVEOF 命令,成为master-server的slave

func SlotsInfo

func SlotsInfo(addr, passwd string, fromSlot, toSlot int) (map[int]int, error)

向某一台redis-sever请求,获取从 fromSlot 到 toSlot 之间的分别属于这些slotId的key的数量

func SlotsMgrtTagSlot

func SlotsMgrtTagSlot(c redis.Conn, slotId int, toAddr string) (int, int, error)

通过向redis发送 SLOTSMGRTTAGSLOT 命令,执行迁移操作

Types

type ConnBuilder

type ConnBuilder interface {
	// Get a conn that will retry automatically when getting error caused by connection issues.
	// If retry can not rebuild the connection, there will be a fetal error
	// 出错后会自动重试,如果重连上限次数,程序会挂掉
	GetSafeConn() zkhelper.Conn

	// Get a conn that will return error caused by connection issues
	// It will try to rebuild the connection after return error.
	GetUnsafeConn() zkhelper.Conn
}

func NewConnBuilder

func NewConnBuilder(buildFunc func() (zkhelper.Conn, error)) ConnBuilder

初始化zk连接相关

type Strings

type Strings []string

func (Strings) Eq

func (s1 Strings) Eq(s2 []string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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