mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: Member.storeKey -> memberStoreKey
This commit is contained in:
parent
7498234e40
commit
89b032cd69
@ -60,7 +60,7 @@ func (s *clusterStore) Add(m Member) {
|
||||
if err != nil {
|
||||
log.Panicf("marshal error: %v", err)
|
||||
}
|
||||
if _, err := s.Store.Create(m.storeKey()+raftAttributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
||||
if _, err := s.Store.Create(memberStoreKey(m.ID)+raftAttributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
||||
log.Panicf("add raftAttributes should never fail: %v", err)
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ func (s *clusterStore) Add(m Member) {
|
||||
if err != nil {
|
||||
log.Panicf("marshal error: %v", err)
|
||||
}
|
||||
if _, err := s.Store.Create(m.storeKey()+attributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
||||
if _, err := s.Store.Create(memberStoreKey(m.ID)+attributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
||||
log.Panicf("add attributes should never fail: %v", err)
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ func nodeToMember(n *store.NodeExtern) (Member, error) {
|
||||
// Remove removes a member from the store.
|
||||
// The given id MUST exist.
|
||||
func (s *clusterStore) Remove(id uint64) {
|
||||
if _, err := s.Store.Delete(Member{ID: id}.storeKey(), true, true); err != nil {
|
||||
if _, err := s.Store.Delete(memberStoreKey(id), true, true); err != nil {
|
||||
log.Panicf("delete peer should never fail: %v", err)
|
||||
}
|
||||
if _, err := s.Store.Create(removedMemberStoreKey(id), false, "", false, store.Permanent); err != nil {
|
||||
|
@ -114,7 +114,7 @@ func TestClusterStoreRemove(t *testing.T) {
|
||||
cs.Remove(1)
|
||||
|
||||
wactions := []action{
|
||||
{name: "Delete", params: []interface{}{Member{ID: 1}.storeKey(), true, true}},
|
||||
{name: "Delete", params: []interface{}{memberStoreKey(1), true, true}},
|
||||
{name: "Create", params: []interface{}{removedMemberStoreKey(1), false, "", false, store.Permanent}},
|
||||
}
|
||||
if !reflect.DeepEqual(st.Action(), wactions) {
|
||||
|
@ -68,8 +68,8 @@ func newMember(name string, peerURLs types.URLs, now *time.Time) *Member {
|
||||
return m
|
||||
}
|
||||
|
||||
func (m Member) storeKey() string {
|
||||
return path.Join(storeMembersPrefix, idAsHex(m.ID))
|
||||
func memberStoreKey(id uint64) string {
|
||||
return path.Join(storeMembersPrefix, idAsHex(id))
|
||||
}
|
||||
|
||||
func parseMemberID(key string) uint64 {
|
||||
|
@ -496,7 +496,7 @@ func (s *EtcdServer) publish(retryInterval time.Duration) {
|
||||
req := pb.Request{
|
||||
ID: GenID(),
|
||||
Method: "PUT",
|
||||
Path: Member{ID: s.id}.storeKey() + attributesSuffix,
|
||||
Path: memberStoreKey(s.id) + attributesSuffix,
|
||||
Val: string(b),
|
||||
}
|
||||
|
||||
|
@ -967,7 +967,7 @@ func TestPublish(t *testing.T) {
|
||||
t.Errorf("method = %s, want PUT", r.Method)
|
||||
}
|
||||
wm := Member{ID: 1, Attributes: Attributes{Name: "node1", ClientURLs: []string{"http://a", "http://b"}}}
|
||||
if w := wm.storeKey() + attributesSuffix; r.Path != w {
|
||||
if w := memberStoreKey(wm.ID) + attributesSuffix; r.Path != w {
|
||||
t.Errorf("path = %s, want %s", r.Path, w)
|
||||
}
|
||||
var gattr Attributes
|
||||
|
Loading…
x
Reference in New Issue
Block a user