etcdserver: etcdserver generates the ID when adding new member.

When adding new member, the etcdserver generates the ID based on the current time
and the given peerurls. We include time to add the uniqueness, since the node with
same peerurls should be able to (add, then remove) several times.
This commit is contained in:
Xiang Li
2014-10-22 11:37:53 -07:00
parent 13656eb4e7
commit d00152765a
5 changed files with 47 additions and 39 deletions

View File

@ -100,7 +100,7 @@ func (c *Cluster) SetMembersFromString(s string) error {
return fmt.Errorf("Empty URL given for %q", name)
}
m := newMember(name, types.URLs(*flags.NewURLsValue(strings.Join(urls, ","))), c.name, nil)
m := NewMember(name, types.URLs(*flags.NewURLsValue(strings.Join(urls, ","))), c.name, nil)
err := c.Add(*m)
if err != nil {
return err
@ -110,7 +110,7 @@ func (c *Cluster) SetMembersFromString(s string) error {
}
func (c *Cluster) AddMemberFromURLs(name string, urls types.URLs) (*Member, error) {
m := newMember(name, urls, c.name, nil)
m := NewMember(name, urls, c.name, nil)
err := c.Add(*m)
if err != nil {
return nil, err