mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: refine comments for Configure
This commit is contained in:
parent
dc36ae7058
commit
ec8f493fde
@ -349,7 +349,7 @@ func (s *EtcdServer) applyConfig(r raftpb.Config) {
|
||||
s.Node.RemoveNode(r.NodeID)
|
||||
default:
|
||||
// This should never be reached
|
||||
panic("unsupported config type")
|
||||
panic("unexpected config type")
|
||||
}
|
||||
}
|
||||
|
||||
|
18
raft/doc.go
18
raft/doc.go
@ -61,16 +61,20 @@ data, serialize it into a byte slice and call:
|
||||
|
||||
n.Propose(ctx, data)
|
||||
|
||||
To add or remove node in a cluster, serialize the data for configuration change
|
||||
into a byte slice and call:
|
||||
To add or remove node in a cluster, build Config struct and call:
|
||||
|
||||
n.Configure(ctx, data)
|
||||
n.Configure(ctx, conf)
|
||||
|
||||
For the safety consideration, one configuration should include at most one node
|
||||
change, which is applied through:
|
||||
After configuration is committed, you should apply it to node through:
|
||||
|
||||
n.AddNode(id)
|
||||
n.RemoveNode(id)
|
||||
var conf raftpb.Config
|
||||
conf.Unmarshal(data)
|
||||
switch conf.Type {
|
||||
case raftpb.ConfigAddNode:
|
||||
n.AddNode(conf.ID)
|
||||
case raftpb.ConfigRemoveNode:
|
||||
n.RemoveNode(conf.ID)
|
||||
}
|
||||
|
||||
*/
|
||||
package raft
|
||||
|
@ -80,8 +80,8 @@ type Node interface {
|
||||
Campaign(ctx context.Context) error
|
||||
// Propose proposes that data be appended to the log.
|
||||
Propose(ctx context.Context, data []byte) error
|
||||
// Configure proposes config change. Only one config can be in the process of going through consensus at a time.
|
||||
// Configure doesn't perform config change.
|
||||
// Configure proposes config change. At most one config can be in the process of going through consensus.
|
||||
// Application needs to call AddNode/RemoveNode when applying EntryConfig type entry.
|
||||
Configure(ctx context.Context, conf pb.Config) error
|
||||
// Step advances the state machine using the given message. ctx.Err() will be returned, if any.
|
||||
Step(ctx context.Context, msg pb.Message) error
|
||||
|
Loading…
x
Reference in New Issue
Block a user