fix(command): change Version to RaftVersion
clear up confusion on what this field is used for: it is for the internal raft protocol version only.
This commit is contained in:
10
command.go
10
command.go
@ -117,7 +117,7 @@ func (c *WatchCommand) Apply(server *raft.Server) (interface{}, error) {
|
|||||||
|
|
||||||
// JoinCommand
|
// JoinCommand
|
||||||
type JoinCommand struct {
|
type JoinCommand struct {
|
||||||
Version string `json:"version"`
|
RaftVersion string `json:"raftVersion"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RaftURL string `json:"raftURL"`
|
RaftURL string `json:"raftURL"`
|
||||||
EtcdURL string `json:"etcdURL"`
|
EtcdURL string `json:"etcdURL"`
|
||||||
@ -125,9 +125,7 @@ type JoinCommand struct {
|
|||||||
|
|
||||||
func newJoinCommand() *JoinCommand {
|
func newJoinCommand() *JoinCommand {
|
||||||
return &JoinCommand{
|
return &JoinCommand{
|
||||||
// TODO: This will be the internal protocol version but tie it
|
RaftVersion: r.version,
|
||||||
// to the release tag for now.
|
|
||||||
Version: r.version,
|
|
||||||
Name: r.name,
|
Name: r.name,
|
||||||
RaftURL: r.url,
|
RaftURL: r.url,
|
||||||
EtcdURL: e.url,
|
EtcdURL: e.url,
|
||||||
@ -156,14 +154,14 @@ func (c *JoinCommand) Apply(raftServer *raft.Server) (interface{}, error) {
|
|||||||
return []byte("join fail"), etcdErr.NewError(103, "")
|
return []byte("join fail"), etcdErr.NewError(103, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
addNameToURL(c.Name, c.Version, c.RaftURL, c.EtcdURL)
|
addNameToURL(c.Name, c.RaftVersion, c.RaftURL, c.EtcdURL)
|
||||||
|
|
||||||
// add peer in raft
|
// add peer in raft
|
||||||
err := raftServer.AddPeer(c.Name, "")
|
err := raftServer.AddPeer(c.Name, "")
|
||||||
|
|
||||||
// add machine in etcd storage
|
// add machine in etcd storage
|
||||||
key := path.Join("_etcd/machines", c.Name)
|
key := path.Join("_etcd/machines", c.Name)
|
||||||
value := fmt.Sprintf("raft=%s&etcd=%s&version=%s", c.RaftURL, c.EtcdURL, c.Version)
|
value := fmt.Sprintf("raft=%s&etcd=%s&raftVersion=%s", c.RaftURL, c.EtcdURL, c.RaftVersion)
|
||||||
etcdStore.Set(key, value, time.Unix(0, 0), raftServer.CommitIndex())
|
etcdStore.Set(key, value, time.Unix(0, 0), raftServer.CommitIndex())
|
||||||
|
|
||||||
return []byte("join success"), err
|
return []byte("join success"), err
|
||||||
|
Reference in New Issue
Block a user