etcdserver: add CompareAndDelete

release-2.0
Blake Mizerany 2014-08-27 11:34:42 -07:00 committed by Yicheng Qin
parent 07c997f98c
commit 5585984ed7
1 changed files with 6 additions and 1 deletions

View File

@ -128,7 +128,12 @@ func (s *Server) apply(ctx context.Context, e raft.Entry) (*store.Event, error)
return s.st.Create(r.Path, r.Dir, r.Val, false, expr)
}
case "DELETE":
return s.st.Delete(r.Path, r.Recursive, r.Dir)
switch {
case r.PrevIndex > 0 || r.PrevValue != "":
return s.st.CompareAndDelete(r.Path, r.PrevValue, r.PrevIndex)
default:
return s.st.Delete(r.Path, r.Recursive, r.Dir)
}
default:
return nil, ErrUnknownMethod
}