Skip to content

Commit

Permalink
Merge pull request #3275 from xiang90/sort
Browse files Browse the repository at this point in the history
improve in order key generation
  • Loading branch information
xiang90 committed Aug 13, 2015
2 parents 003d096 + a7b9bff commit 959feb7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job1
"action": "create",
"node": {
"createdIndex": 6,
"key": "/queue/6",
"key": "/queue/00000000000000000006",
"modifiedIndex": 6,
"value": "Job1"
}
Expand All @@ -399,7 +399,7 @@ curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job2
"action": "create",
"node": {
"createdIndex": 29,
"key": "/queue/29",
"key": "/queue/00000000000000000029",
"modifiedIndex": 29,
"value": "Job2"
}
Expand All @@ -423,13 +423,13 @@ curl -s 'http://127.0.0.1:2379/v2/keys/queue?recursive=true&sorted=true'
"nodes": [
{
"createdIndex": 2,
"key": "/queue/2",
"key": "/queue/00000000000000000002",
"modifiedIndex": 2,
"value": "Job1"
},
{
"createdIndex": 3,
"key": "/queue/3",
"key": "/queue/00000000000000000003",
"modifiedIndex": 3,
"value": "Job2"
}
Expand Down
6 changes: 3 additions & 3 deletions integration/v2_http_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ func TestV2Unique(t *testing.T) {
http.StatusCreated,
map[string]interface{}{
"node": map[string]interface{}{
"key": "/foo/4",
"key": "/foo/00000000000000000004",
"value": "XXX",
},
"action": "create",
Expand All @@ -553,7 +553,7 @@ func TestV2Unique(t *testing.T) {
http.StatusCreated,
map[string]interface{}{
"node": map[string]interface{}{
"key": "/foo/5",
"key": "/foo/00000000000000000005",
"value": "XXX",
},
"action": "create",
Expand All @@ -565,7 +565,7 @@ func TestV2Unique(t *testing.T) {
http.StatusCreated,
map[string]interface{}{
"node": map[string]interface{}{
"key": "/bar/6",
"key": "/bar/00000000000000000006",
"value": "XXX",
},
"action": "create",
Expand Down
2 changes: 1 addition & 1 deletion store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique,
currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1

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))
Expand Down

0 comments on commit 959feb7

Please sign in to comment.