You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to implement a distributed KV system with data sharding based on consistent hash , which involves the need to re-shard and transfer the cluster data after the cluster leader changes.I see that etcd does not provide a notification mechanism, but hashiCorp/raft does provide LeaderCh and NotifyCh to actively notify the application layer that the leader has changed.
In the implementation of this system, in addition to the above functions, a preVote function is required, but this function is not implemented in hashicorp/raft. So eventually I have to resort to etcd/raft. So I'd like to ask if you have that notification mechanism in your implementation of raft, or if there are other better suggestions
The text was updated successfully, but these errors were encountered:
The entire asynchronous Raft pattern and signaling are kept internal to this library and are not exposed publicly for specific reasons. Nevertheless, you can obtain leader transfer signals by implementing a simple function that ticks every X interval and compares the leader's IDs.
funcmonit(n*raft.node) {
ticker:=time.NewTicker(100*time.Millisecond)
deferticker.Stop()
varleaderuint64for {
select {
case<-ticker.C:
ifid:=node.Leader(); id>leader {
fmt.Println("leader changed")
leader=idifnode.Whoami() ==leader {
fmt.Println("this member promoted to be the raft leader")
}
}
}
}
}
I want to implement a distributed KV system with data sharding based on consistent hash , which involves the need to re-shard and transfer the cluster data after the cluster leader changes.I see that etcd does not provide a notification mechanism, but hashiCorp/raft does provide LeaderCh and NotifyCh to actively notify the application layer that the leader has changed.
In the implementation of this system, in addition to the above functions, a preVote function is required, but this function is not implemented in hashicorp/raft. So eventually I have to resort to etcd/raft. So I'd like to ask if you have that notification mechanism in your implementation of raft, or if there are other better suggestions
The text was updated successfully, but these errors were encountered: