mirror of
https://github.com/HDT3213/godis.git
synced 2025-11-03 02:53:57 +08:00
raft cluster
wip: raft does not care about migrating wip: optimize code wip: raft election wip wip: fix raft leader missing log entries wip fix a dead lock batch set slot route wip: raft persist wip refactor cluster suite remove relay rename relay2 refactor: allow customizing client factory test raft refactor re-balance avoid errors caused by inconsistent status on follower nodes during raft commits test raft election
This commit is contained in:
@@ -7,19 +7,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
relayPublish = "_publish"
|
||||
publish = "publish"
|
||||
)
|
||||
|
||||
var (
|
||||
publishRelayCmd = []byte(relayPublish)
|
||||
publishCmd = []byte(publish)
|
||||
relayPublish = "publish_"
|
||||
)
|
||||
|
||||
// Publish broadcasts msg to all peers in cluster when receive publish command from client
|
||||
func Publish(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
|
||||
func Publish(cluster *Cluster, c redis.Connection, cmdLine [][]byte) redis.Reply {
|
||||
var count int64 = 0
|
||||
results := cluster.broadcast(c, args)
|
||||
results := cluster.broadcast(c, modifyCmd(cmdLine, relayPublish))
|
||||
for _, val := range results {
|
||||
if errReply, ok := val.(protocol.ErrorReply); ok {
|
||||
logger.Error("publish occurs error: " + errReply.Error())
|
||||
@@ -30,12 +24,6 @@ func Publish(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
|
||||
return protocol.MakeIntReply(count)
|
||||
}
|
||||
|
||||
// onRelayedPublish receives publish command from peer, just publish to local subscribing clients, do not relay to peers
|
||||
func onRelayedPublish(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
|
||||
args[0] = publishCmd
|
||||
return cluster.db.Exec(c, args) // let local db.hub handle publish
|
||||
}
|
||||
|
||||
// Subscribe puts the given connection into the given channel
|
||||
func Subscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
|
||||
return cluster.db.Exec(c, args) // let local db.hub handle subscribe
|
||||
|
||||
Reference in New Issue
Block a user