mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3275 from xiang90/sort
improve in order key generation
This commit is contained in:
commit
959feb70d1
@ -380,7 +380,7 @@ curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job1
|
|||||||
"action": "create",
|
"action": "create",
|
||||||
"node": {
|
"node": {
|
||||||
"createdIndex": 6,
|
"createdIndex": 6,
|
||||||
"key": "/queue/6",
|
"key": "/queue/00000000000000000006",
|
||||||
"modifiedIndex": 6,
|
"modifiedIndex": 6,
|
||||||
"value": "Job1"
|
"value": "Job1"
|
||||||
}
|
}
|
||||||
@ -399,7 +399,7 @@ curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job2
|
|||||||
"action": "create",
|
"action": "create",
|
||||||
"node": {
|
"node": {
|
||||||
"createdIndex": 29,
|
"createdIndex": 29,
|
||||||
"key": "/queue/29",
|
"key": "/queue/00000000000000000029",
|
||||||
"modifiedIndex": 29,
|
"modifiedIndex": 29,
|
||||||
"value": "Job2"
|
"value": "Job2"
|
||||||
}
|
}
|
||||||
@ -423,13 +423,13 @@ curl -s 'http://127.0.0.1:2379/v2/keys/queue?recursive=true&sorted=true'
|
|||||||
"nodes": [
|
"nodes": [
|
||||||
{
|
{
|
||||||
"createdIndex": 2,
|
"createdIndex": 2,
|
||||||
"key": "/queue/2",
|
"key": "/queue/00000000000000000002",
|
||||||
"modifiedIndex": 2,
|
"modifiedIndex": 2,
|
||||||
"value": "Job1"
|
"value": "Job1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"createdIndex": 3,
|
"createdIndex": 3,
|
||||||
"key": "/queue/3",
|
"key": "/queue/00000000000000000003",
|
||||||
"modifiedIndex": 3,
|
"modifiedIndex": 3,
|
||||||
"value": "Job2"
|
"value": "Job2"
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ func TestV2Unique(t *testing.T) {
|
|||||||
http.StatusCreated,
|
http.StatusCreated,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"node": map[string]interface{}{
|
"node": map[string]interface{}{
|
||||||
"key": "/foo/4",
|
"key": "/foo/00000000000000000004",
|
||||||
"value": "XXX",
|
"value": "XXX",
|
||||||
},
|
},
|
||||||
"action": "create",
|
"action": "create",
|
||||||
@ -553,7 +553,7 @@ func TestV2Unique(t *testing.T) {
|
|||||||
http.StatusCreated,
|
http.StatusCreated,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"node": map[string]interface{}{
|
"node": map[string]interface{}{
|
||||||
"key": "/foo/5",
|
"key": "/foo/00000000000000000005",
|
||||||
"value": "XXX",
|
"value": "XXX",
|
||||||
},
|
},
|
||||||
"action": "create",
|
"action": "create",
|
||||||
@ -565,7 +565,7 @@ func TestV2Unique(t *testing.T) {
|
|||||||
http.StatusCreated,
|
http.StatusCreated,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"node": map[string]interface{}{
|
"node": map[string]interface{}{
|
||||||
"key": "/bar/6",
|
"key": "/bar/00000000000000000006",
|
||||||
"value": "XXX",
|
"value": "XXX",
|
||||||
},
|
},
|
||||||
"action": "create",
|
"action": "create",
|
||||||
|
@ -495,7 +495,7 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique,
|
|||||||
currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1
|
currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1
|
||||||
|
|
||||||
if unique { // append unique item under the node path
|
if unique { // append unique item under the node path
|
||||||
nodePath += "/" + strconv.FormatUint(nextIndex, 10)
|
nodePath += "/" + fmt.Sprintf("%020s", strconv.FormatUint(nextIndex, 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
nodePath = path.Clean(path.Join("/", nodePath))
|
nodePath = path.Clean(path.Join("/", nodePath))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user