Error:'function undefined' when calling a new added function in raft.Node interface #16344
-
I add a new function imitaing Propose() in raft.Node interface. But there is 'undefined' error when it is called at processInternalRaftRequestOnce() replacing the origin Propose(). I noticed that #5997 may be related but I still don't know how to solve this problem. // raft/node.go
type Node interface {
ProposeWithKey(ctx context.Context, data []byte, key []byte) error
Propose(ctx context.Context, data []byte) error
}
func (n *node) ProposeWithKey(ctx context.Context, data []byte, key []byte) error {
return n.stepWait(ctx, pb.Message{Type: pb.MsgProp, Entries: []pb.Entry{{Data: data, SfKey: key}}})
}
func (n *node) Propose(ctx context.Context, data []byte) error {
return n.stepWait(ctx, pb.Message{Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
} // v3_server.go
func (s *EtcdServer) processInternalRaftRequestOnce(ctx context.Context, r pb.InternalRaftRequest) (*applyResult, error) {
err = s.r.ProposeWithKey(cctx, data, key) // error: s.r.ProposeWithKey undefined (type raftNode has no field or method sf_ProposeWithKey)
err = s.r.Propose(cctx, data)
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I figure out the problem! |
Beta Was this translation helpful? Give feedback.
I figure out the problem!
The reason is that the first letter of the function is not capitalized.
The problem is unrelated to etcd. As a beginner in go, I don't know that and find it occasionally.