Only write to etcd if values have changed
This prevents certain loops from writing data to etcd every few seconds (when data hasn't changed).
This commit is contained in:
@@ -249,7 +249,7 @@ type EtcdUpdateFunc func(input interface{}) (output interface{}, err error)
|
||||
// // Before this function is called, currentObj has been reset to etcd's current
|
||||
// // contents for "myKey".
|
||||
//
|
||||
// cur := input.(*MyType) // Gauranteed to work.
|
||||
// cur := input.(*MyType) // Guaranteed to work.
|
||||
//
|
||||
// // Make a *modification*.
|
||||
// cur.Counter++
|
||||
@@ -290,6 +290,10 @@ func (h *EtcdHelper) AtomicUpdate(key string, ptrToType interface{}, tryUpdate E
|
||||
return err
|
||||
}
|
||||
|
||||
if string(data) == origBody {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = h.Client.CompareAndSwap(key, string(data), 0, origBody, index)
|
||||
if IsEtcdTestFailed(err) {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user