Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RaftNode ¶
type RaftNode struct { sync.Mutex // 保证某些情况下的并发安全 pb.UnimplementedRaftServer // 保证实现了 RaftServer 接口 Address string // 节点地址 Role Role // 当前节点的角色 Term int32 // 当前任期 CommitIndex int32 // 已提交的日志索引 Logs []*pb.LogEntry // 日志 LogsBuffer []*pb.LogEntry // 日志缓冲区 Peers []string // 集群中的其他节点地址 Clients map[string]pb.RaftClient // 与其他节点的gRPC客户端 // debug Wg sync.WaitGroup // contains filtered or unexported fields }
func NewRaftNode ¶
func (*RaftNode) AppendEntry ¶
func (r *RaftNode) AppendEntry(ctx context.Context, req *pb.AppendEntryRequest) (*pb.AppendEntryResponse, error)
实现RaftServer接口,执行一致性操作
func (*RaftNode) HandleInConsistency ¶
Click to show internal directories.
Click to hide internal directories.