Documentation
¶
Overview ¶
Package cluster provides a server side cluster which is transparent to client. You can connect to any node in the cluster to access all data in the cluster
Index ¶
- func Copy(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply
- func Del(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply
- func FlushAll(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply
- func FlushDB(cluster *Cluster, c redis.Connection, cmdLine [][]byte) redis.Reply
- func MGet(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply
- func MSet(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply
- func MSetNX(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply
- func Publish(cluster *Cluster, c redis.Connection, cmdLine [][]byte) redis.Reply
- func Rename(cluster *Cluster, c redis.Connection, cmdLine [][]byte) redis.Reply
- func RenameNx(cluster *Cluster, c redis.Connection, cmdLine [][]byte) redis.Reply
- func Subscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply
- func UnSubscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply
- type Cluster
- func (cluster *Cluster) AfterClientClose(c redis.Connection)
- func (cluster *Cluster) Close()
- func (cluster *Cluster) Exec(c redis.Connection, cmdLine [][]byte) (result redis.Reply)
- func (cluster *Cluster) Join(seed string) protocol.ErrorReply
- func (cluster *Cluster) LoadConfig() protocol.ErrorReply
- func (cluster *Cluster) LoadRDB(dec *core.Decoder) error
- type CmdFunc
- type CmdLine
- type Node
- type Raft
- func (raft *Raft) Close() error
- func (raft *Raft) GetNode(nodeID string) *Node
- func (raft *Raft) GetNodes() []*Node
- func (raft *Raft) GetSelfNodeID() string
- func (raft *Raft) GetSlots() []*Slot
- func (raft *Raft) Join(seed string) protocol.ErrorReply
- func (raft *Raft) LoadConfigFile() protocol.ErrorReply
- func (raft *Raft) NewNode(addr string) (*Node, error)
- func (raft *Raft) SetSlot(slotIDs []uint32, newNodeID string) protocol.ErrorReply
- func (raft *Raft) StartAsSeed(listenAddr string) protocol.ErrorReply
- type Slot
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy copies the value stored at the source key to the destination key. the origin and the destination must within the same node.
func Del ¶
Del atomically removes given writeKeys from cluster, writeKeys can be distributed on any node if the given writeKeys are distributed on different node, Del will use try-commit-catch to remove them
func MGet ¶
MGet atomically get multi key-value from cluster, writeKeys can be distributed on any node
func MSet ¶
MSet atomically sets multi key-value in cluster, writeKeys can be distributed on any node
func MSetNX ¶
MSetNX sets multi key-value in database, only if none of the given writeKeys exist and all given writeKeys are on the same node
func Publish ¶
Publish broadcasts msg to all peers in cluster when receive publish command from client
func RenameNx ¶
RenameNx renames a key, only if the new key does not exist. The origin and the destination must within the same node
func UnSubscribe ¶
UnSubscribe removes the given connection from the given channel
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster represents a node of godis cluster it holds part of data and coordinates other nodes to finish transactions
func (*Cluster) AfterClientClose ¶
func (cluster *Cluster) AfterClientClose(c redis.Connection)
AfterClientClose does some clean after client close connection
func (*Cluster) Join ¶
func (cluster *Cluster) Join(seed string) protocol.ErrorReply
Join send `gcluster join` to node in cluster to join
func (*Cluster) LoadConfig ¶
func (cluster *Cluster) LoadConfig() protocol.ErrorReply
LoadConfig try to load cluster-config-file and re-join the cluster
type Node ¶
type Node struct {
ID string
Addr string
Slots []*Slot // ascending order by slot id
Flags uint32
// contains filtered or unexported fields
}
Node represents a node and its slots, used in cluster internal messages
type Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
func (*Raft) GetSelfNodeID ¶
GetSelfNodeID returns node id of current node
func (*Raft) LoadConfigFile ¶
func (raft *Raft) LoadConfigFile() protocol.ErrorReply
func (*Raft) SetSlot ¶
func (raft *Raft) SetSlot(slotIDs []uint32, newNodeID string) protocol.ErrorReply
SetSlot propose
func (*Raft) StartAsSeed ¶
func (raft *Raft) StartAsSeed(listenAddr string) protocol.ErrorReply
StartAsSeed starts cluster as seed node
type Slot ¶
type Slot struct {
// ID is uint between 0 and 16383
ID uint32
// NodeID is id of the hosting node
// If the slot is migrating, NodeID is the id of the node importing this slot (target node)
NodeID string
// Flags stores more information of slot
Flags uint32
}
Slot represents a hash slot, used in cluster internal messages
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction stores state and data for a try-commit-catch distributed transaction
func NewTransaction ¶
func NewTransaction(cluster *Cluster, c redis.Connection, id string, cmdLine [][]byte) *Transaction
NewTransaction creates a try-commit-catch distributed transaction