admin

package
v0.0.0-...-24f4e42 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 3 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
	// AddrError map from address to error returned from the function
	AddrError map[string]error
	// GetClusterInfosRet returned value for GetClusterInfos function
	GetClusterInfosRet ClusterInfosRetType
	// GetClusterInfosSelectedRet returned value for GetClusterInfos function
	GetClusterInfosSelectedRet ClusterInfosRetType
	// GetKeysInSlotRet map of returned data for GetKeysInSlot function
	GetKeysInSlotRet map[string]GetKeysInSlotRetType
	// CountKeysInSlotRet map of returned data for CountKeysInSlot function
	CountKeysInSlotRet map[string]CountKeysInSlotRetType
	// GetKeysRet map of returned data for GetKeys function
	GetKeysRet map[string]GetKeysInSlotRetType
	// 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() *Admin

NewFakeAdmin returns new AdminInterface for fake admin

func (*Admin) AddSlots

func (a *Admin) AddSlots(ctx context.Context, addr string, slots redis.SlotSlice) error

AddSlots uses ADDSLOT command on several slots

func (*Admin) AttachNodeToCluster

func (a *Admin) AttachNodeToCluster(ctx context.Context, addr string) error

AttachNodeToCluster connects a node to the cluster

func (*Admin) AttachReplicaToPrimary

func (a *Admin) AttachReplicaToPrimary(ctx context.Context, replica *redis.Node, primary *redis.Node) error

AttachReplicaToPrimary attaches a replica to a primary node

func (*Admin) Close

func (a *Admin) Close()

Close closes all possible resources instantiated by the Admin

func (*Admin) Connections

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

Connections returns a connection map

func (*Admin) CountKeysInSlot

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

CountKeysInSlot counts the keys in the given slot

func (*Admin) DelSlots

func (a *Admin) DelSlots(ctx context.Context, addr string, slots redis.SlotSlice) error

DelSlots deletes slots in a pipeline

func (*Admin) DeleteKeys

func (a *Admin) DeleteKeys(ctx context.Context, addr string, keys []string) error

DeleteKeys uses DEL command to delete multiple keys

func (*Admin) DetachReplica

func (a *Admin) DetachReplica(ctx context.Context, replica *redis.Node) error

DetachReplica detaches a replica from a primary

func (*Admin) FlushAll

func (a *Admin) FlushAll(ctx context.Context, addr string) error

FlushAll flushes all keys in cluster

func (*Admin) FlushAndReset

func (a *Admin) FlushAndReset(ctx context.Context, addr string, mode string) error

FlushAndReset resets the cluster configuration of the node

func (*Admin) ForgetNode

func (a *Admin) ForgetNode(ctx context.Context, addr string) error

ForgetNode forces a redis cluster node to forget a specific node

func (*Admin) ForgetNodeByAddr

func (a *Admin) ForgetNodeByAddr(ctx context.Context, addr string) error

ForgetNodeByAddr forces a redis cluster node to forget a specific node by address

func (*Admin) GetClusterInfos

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

GetClusterInfos returns redis cluster info from all clients

func (*Admin) GetClusterInfosSelected

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

GetClusterInfosSelected returns selected redis cluster info from all clients

func (*Admin) GetConfig

func (a *Admin) GetConfig(ctx context.Context, pattern string) (map[string]string, error)

GetConfig gets the running redis server configuration matching the pattern

func (*Admin) GetHashMaxSlot

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

GetHashMaxSlot gets the max slot value

func (*Admin) GetKeys

func (a *Admin) GetKeys(ctx context.Context, addr string, slot redis.Slot, batch string) ([]string, error)

GetKeys uses GETKEYSINSLOT command to get keys in a slot Number of keys returned specified by batch

func (*Admin) GetKeysInSlot

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

GetKeysInSlot gets the keys in the given slot

func (*Admin) InitRedisCluster

func (a *Admin) InitRedisCluster(ctx context.Context, addr string) error

InitRedisCluster init a single node redis cluster

func (*Admin) MigrateKeys

func (a *Admin) MigrateKeys(ctx context.Context, source *redis.Node, dest *redis.Node, slots redis.SlotSlice, conf *rapi.RedisClusterSpec, replace, scaling bool, primaries redis.Nodes) error

MigrateKeys migrates keys from slots to other slots

func (*Admin) RebuildConnectionMap

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

RebuildConnectionMap rebuilds the connection map according to the given addresses

func (*Admin) SetConfig

func (a *Admin) SetConfig(ctx context.Context, addr string, config []string) error

SetConfig sets the specified redis server configuration

func (*Admin) SetSlot

func (a *Admin) SetSlot(ctx context.Context, addr, action string, slot redis.Slot, node *redis.Node) error

SetSlot uses SETSLOT command on a single slot

func (*Admin) SetSlots

func (a *Admin) SetSlots(ctx context.Context, addr, action string, slots redis.SlotSlice, nodeID string, retryAttempt int) error

SetSlots uses SETSLOT command on several slots

func (*Admin) StartFailover

func (a *Admin) StartFailover(ctx context.Context, addr string) error

StartFailover forces the failover of a specific redis primary 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(ctx context.Context, addr string) error

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

func (*Connections) AddAll

func (cnx *Connections) AddAll(ctx context.Context, 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 instantiate by the Connections

func (*Connections) Get

func (cnx *Connections) Get(ctx context.Context, 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(ctx context.Context, addr string) error

Reconnect force a reconnection on the given address is the address 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(ctx context.Context, 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) ValidateResp

func (cnx *Connections) ValidateResp(ctx context.Context, resp interface{}, err error, addr, errMessage string) error

ValidateResp checks if the redis resp is empty and will attempt to 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

Jump to

Keyboard shortcuts

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