mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add newJoinCommand func().
This commit is contained in:
committed by
Brandon Philips
parent
ca4b5815f7
commit
e0ca8f20d2
@@ -121,6 +121,14 @@ type JoinCommand struct {
|
||||
EtcdURL string `json:"etcdURL"`
|
||||
}
|
||||
|
||||
func newJoinCommand() *JoinCommand {
|
||||
return &JoinCommand{
|
||||
Name: r.name,
|
||||
RaftURL: r.url,
|
||||
EtcdURL: e.url,
|
||||
}
|
||||
}
|
||||
|
||||
// The name of the join command in the log
|
||||
func (c *JoinCommand) CommandName() string {
|
||||
return commandName("join")
|
||||
|
||||
@@ -74,12 +74,7 @@ func (r *raftServer) start() {
|
||||
|
||||
// leader need to join self as a peer
|
||||
for {
|
||||
command := &JoinCommand{
|
||||
Name: r.name,
|
||||
RaftURL: r.url,
|
||||
EtcdURL: e.url,
|
||||
}
|
||||
_, err := server.Do(command)
|
||||
_, err := server.Do(newJoinCommand())
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
@@ -173,13 +168,7 @@ func (r *raftServer) startTransport(scheme string, tlsConf tls.Config) {
|
||||
func joinCluster(s *raft.Server, raftURL string, scheme string) error {
|
||||
var b bytes.Buffer
|
||||
|
||||
command := &JoinCommand{
|
||||
Name: s.Name(),
|
||||
RaftURL: r.url,
|
||||
EtcdURL: e.url,
|
||||
}
|
||||
|
||||
json.NewEncoder(&b).Encode(command)
|
||||
json.NewEncoder(&b).Encode(newJoinCommand())
|
||||
|
||||
// t must be ok
|
||||
t, ok := r.server.Transporter().(transporter)
|
||||
@@ -208,7 +197,7 @@ func joinCluster(s *raft.Server, raftURL string, scheme string) error {
|
||||
address := resp.Header.Get("Location")
|
||||
debugf("Send Join Request to %s", address)
|
||||
|
||||
json.NewEncoder(&b).Encode(command)
|
||||
json.NewEncoder(&b).Encode(newJoinCommand())
|
||||
|
||||
resp, err = t.Post(address, &b)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user