Browse Source

feat add modifiedIndex in kvpair

Xiang Li 12 years ago
parent
commit
cb4b6f1fe4
2 changed files with 13 additions and 10 deletions
  1. 7 6
      store/kv_pairs.go
  2. 6 4
      store/node.go

+ 7 - 6
store/kv_pairs.go

@@ -6,12 +6,13 @@ import (
 
 // When user list a directory, we add all the node into key-value pair slice
 type KeyValuePair struct {
-	Key        string     `json:"key, omitempty"`
-	Value      string     `json:"value,omitempty"`
-	Dir        bool       `json:"dir,omitempty"`
-	Expiration *time.Time `json:"expiration,omitempty"`
-	TTL        int64      `json:"ttl,omitempty"` // Time to live in second
-	KVPairs    kvPairs    `json:"kvs,omitempty"`
+	Key           string     `json:"key, omitempty"`
+	Value         string     `json:"value,omitempty"`
+	Dir           bool       `json:"dir,omitempty"`
+	Expiration    *time.Time `json:"expiration,omitempty"`
+	TTL           int64      `json:"ttl,omitempty"` // Time to live in second
+	KVPairs       kvPairs    `json:"kvs,omitempty"`
+	ModifiedIndex uint64     `json:"modifiedIndex,omitempty"`
 }
 
 type kvPairs []KeyValuePair

+ 6 - 4
store/node.go

@@ -226,8 +226,9 @@ func (n *Node) Remove(recursive bool, callback func(path string)) *etcdErr.Error
 func (n *Node) Pair(recurisive, sorted bool) KeyValuePair {
 	if n.IsDir() {
 		pair := KeyValuePair{
-			Key: n.Path,
-			Dir: true,
+			Key:           n.Path,
+			Dir:           true,
+			ModifiedIndex: n.ModifiedIndex,
 		}
 		pair.Expiration, pair.TTL = n.ExpirationAndTTL()
 
@@ -263,8 +264,9 @@ func (n *Node) Pair(recurisive, sorted bool) KeyValuePair {
 	}
 
 	pair := KeyValuePair{
-		Key:   n.Path,
-		Value: n.Value,
+		Key:           n.Path,
+		Value:         n.Value,
+		ModifiedIndex: n.ModifiedIndex,
 	}
 	pair.Expiration, pair.TTL = n.ExpirationAndTTL()
 	return pair