admin

package
v0.0.0-...-f651441 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	// HashMaxSlots Max slot value
	HashMaxSlots redis.Slot
	// InitRedisClusterRet map of returned error for InitRedisCluster function
	InitRedisClusterRet map[string]error
	// GetClusterInfosRet returned value for GetClusterInfos function
	GetClusterInfosRet ClusterInfosRetType
	// GetClusterInfosSelectedRet returned value for GetClusterInfos function
	GetClusterInfosSelectedRet ClusterInfosRetType
	// AttachNodeToClusterRet map of returned error for AttachNodeToCluster function
	AttachNodeToClusterRet map[string]error
	// UpdateClientsRet map of returned error for UpdateClients function
	UpdateClientsRet map[string]error
	// StartFailoverRet map of returned error for StartFailover function
	StartFailoverRet map[string]error
	// ForgetNodeRet map of returned error for ForgetNode function
	ForgetNodeRet map[string]error
	// SetSlotsRet map of returned error for SetSlots function
	SetSlotsRet map[string]error
	// AddSlotsRet map of returned error for AddSlots function
	AddSlotsRet map[string]error
	// DelSlotsRet map of returned error for DellSlots function
	DelSlotsRet map[string]error
	// GetKeysInSlotRet map of returned data for GetKeysInSlot function
	GetKeysInSlotRet map[string]GetKeysInSlotRetType
	// CountKeysInSlotRet map of returned data for for CountKeysInSlot function
	CountKeysInSlotRet map[string]CountKeysInSlotRetType
	// MigrateKeysRet map of returned error for MigrateKeys function
	MigrateKeysRet map[string]MigrateKeyRetType
	// AttachSlaveToMasterRet map of returned error for AttachSlaveToMaster function
	AttachSlaveToMasterRet map[string]error
	// DetachSlaveToMasterRet map of returned error for DetachSlave function
	DetachSlaveToMasterRet map[string]error
	// ResetRet map of returned error for FlushAndReset function
	FlushAndResetRet map[string]error
	// contains filtered or unexported fields
}

Admin representation of a fake redis admin, where all return error for fake admin commands are configurable per addr, and return nil by default

func NewFakeAdmin

func NewFakeAdmin(addrs []string) *Admin

NewFakeAdmin returns new AdminInterface for fake admin

func (*Admin) AddSlots

func (a *Admin) AddSlots(addr string, slots []redis.Slot) error

AddSlots use to set ADDSLOT command on several slots

func (*Admin) AttachNodeToCluster

func (a *Admin) AttachNodeToCluster(addr string) error

AttachNodeToCluster command use to connect a Node to the cluster

func (*Admin) AttachSlaveToMaster

func (a *Admin) AttachSlaveToMaster(slave *redis.Node, master *redis.Node) error

AttachSlaveToMaster attach a slave to a master node

func (*Admin) Close

func (a *Admin) Close()

Close used to close all possible resources instanciate by the Admin

func (*Admin) Connections

func (a *Admin) Connections() redis.AdminConnectionsInterface

Connections returns a connection map

func (*Admin) CountKeysInSlot

func (a *Admin) CountKeysInSlot(addr string, node redis.Slot) (int64, error)

CountKeysInSlot exec the redis command to count the keys in the given slot of the node

func (*Admin) DelSlots

func (a *Admin) DelSlots(addr string, slots []redis.Slot) error

DelSlots exec the redis command to del slots in a pipeline

func (*Admin) DetachSlave

func (a *Admin) DetachSlave(slave *redis.Node) error

DetachSlave dettach a slave to its master

func (*Admin) FlushAll

func (a *Admin) FlushAll()

FlushAll flush all keys in cluster

func (*Admin) FlushAndReset

func (a *Admin) FlushAndReset(addr string, mode string) error

FlushAndReset reset the cluster configuration of the node, also flush in the same pipe

func (*Admin) ForgetNode

func (a *Admin) ForgetNode(addr string) error

ForgetNode used to force other redis cluster node to forget a specific node

func (*Admin) ForgetNodeByAddr

func (a *Admin) ForgetNodeByAddr(addr string) error

ForgetNodeByAddr used to force other redis cluster node to forget a specific node

func (*Admin) GetClusterInfos

func (a *Admin) GetClusterInfos() (*redis.ClusterInfos, error)

GetClusterInfos returns redis cluster infos from all clients

func (*Admin) GetClusterInfosSelected

func (a *Admin) GetClusterInfosSelected(addr []string) (*redis.ClusterInfos, error)

GetClusterInfosSelected returns redis cluster infos from all clients

func (*Admin) GetHashMaxSlot

func (a *Admin) GetHashMaxSlot() redis.Slot

GetHashMaxSlot get the max slot value

func (*Admin) GetKeysInSlot

func (a *Admin) GetKeysInSlot(addr string, node redis.Slot, batch int, limit bool) ([]string, error)

GetKeysInSlot exec the redis command to get the keys in the given slot on the node we are connected to

func (*Admin) InitRedisCluster

func (a *Admin) InitRedisCluster(addr string) error

InitRedisCluster used to init a single node redis cluster

func (*Admin) MigrateKeys

func (a *Admin) MigrateKeys(addr string, dest *redis.Node, slots []redis.Slot, batch, timeout int, replace bool) (int, error)

MigrateKeys use to migrate keys from slots to other slots

func (*Admin) RebuildConnectionMap

func (a *Admin) RebuildConnectionMap(addrs []string, options *redis.AdminOptions)

RebuildConnectionMap rebuild the connection map according to the given addresse

func (*Admin) SetSlots

func (a *Admin) SetSlots(addr, action string, slots []redis.Slot, nodeID string) error

SetSlots use to set SETSLOT command on several slots

func (*Admin) StartFailover

func (a *Admin) StartFailover(addr string) error

StartFailover used to force the failover of a specific redis master node

type ClusterInfosRetType

type ClusterInfosRetType struct {
	ClusterInfos *redis.ClusterInfos
	Err          error
}

ClusterInfosRetType structure to describe the return data of GetClusterInfosRet method

type Connections

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

Connections fake redis connection handler, do nothing

func (*Connections) Add

func (cnx *Connections) Add(addr string) error

Add connect to the given address and register the client connection to the map

func (*Connections) AddAll

func (cnx *Connections) AddAll(addrs []string)

AddAll connect to the given list of addresses and register them in the map fail silently

func (*Connections) Close

func (cnx *Connections) Close()

Close used to close all possible resources instanciate by the Connections

func (*Connections) Get

func (cnx *Connections) Get(addr string) (redis.ClientInterface, error)

Get returns a client connection for the given adress, connects if the connection is not in the map yet

func (*Connections) GetAll

func (cnx *Connections) GetAll() map[string]redis.ClientInterface

GetAll returns a map of all clients per address

func (*Connections) GetDifferentFrom

func (cnx *Connections) GetDifferentFrom(addr string) (redis.ClientInterface, error)

GetDifferentFrom returns random a client connection different from given address

func (*Connections) GetRandom

func (cnx *Connections) GetRandom() (redis.ClientInterface, error)

GetRandom returns a client connection to a random node of the client map

func (*Connections) GetSelected

func (cnx *Connections) GetSelected(addrs []string) map[string]redis.ClientInterface

GetSelected returns a map of all clients per address

func (*Connections) Reconnect

func (cnx *Connections) Reconnect(addr string) error

Reconnect force a reconnection on the given address is the adress is not part of the map, act like Add

func (*Connections) Remove

func (cnx *Connections) Remove(addr string)

Remove disconnect and remove the client connection from the map

func (*Connections) ReplaceAll

func (cnx *Connections) ReplaceAll(addrs []string)

ReplaceAll clear the pool and re-populate it with new connections fail silently

func (*Connections) Reset

func (cnx *Connections) Reset()

Reset close all connections and clear the connection map

func (*Connections) ValidatePipeResp

func (cnx *Connections) ValidatePipeResp(client redis.ClientInterface, addr, errMessage string) bool

ValidatePipeResp wait for all answers in the pipe and validate the response in case of network issue clear the pipe and return in case of error, return false

func (*Connections) ValidateResp

func (cnx *Connections) ValidateResp(resp *radix.Resp, addr, errMessage string) error

ValidateResp check the redis resp, eventually reconnect on connection error in case of error, customize the error, log it and return it

type CountKeysInSlotRetType

type CountKeysInSlotRetType struct {
	NbKeys int64
	Err    error
}

CountKeysInSlotRetType structure to describe the return data of CountKeysInSlot method

type GetClusterInfoRetType

type GetClusterInfoRetType struct {
	Nodes redis.Nodes
	Err   error
}

GetClusterInfoRetType structure to describe the return data of GetClusterInfo method

type GetKeysInSlotRetType

type GetKeysInSlotRetType struct {
	Keys []string
	Err  error
}

GetKeysInSlotRetType structure to describe the return data of GetKeysInSlot method

type MigrateKeyRetType

type MigrateKeyRetType struct {
	Nb  int
	Err error
}

MigrateKeyRetType structure to describe the return data of the MigrateKey method

Jump to

Keyboard shortcuts

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