etcdserver: give update/create higher priority

This commit is contained in:
Blake Mizerany 2014-08-27 11:38:25 -07:00 committed by Yicheng Qin
parent 5585984ed7
commit e79e9c4853

View File

@ -120,10 +120,10 @@ func (s *Server) apply(ctx context.Context, e raft.Entry) (*store.Event, error)
return s.st.Create(r.Path, r.Dir, r.Val, true, expr)
case "PUT":
switch {
case r.PrevIndex > 0 || r.PrevValue != "":
return s.st.CompareAndSwap(r.Path, r.PrevValue, r.PrevIndex, r.Val, expr)
case r.PrevExists:
return s.st.Update(r.Path, r.Val, expr)
case r.PrevIndex > 0 || r.PrevValue != "":
return s.st.CompareAndSwap(r.Path, r.PrevValue, r.PrevIndex, r.Val, expr)
default:
return s.st.Create(r.Path, r.Dir, r.Val, false, expr)
}