client: add Nodes type to faciliate sorting
This helps users to sort easily.release-2.3
parent
db0511e28c
commit
eb51901830
|
@ -279,7 +279,7 @@ type Node struct {
|
||||||
// Nodes holds the children of this Node, only if this Node is a directory.
|
// Nodes holds the children of this Node, only if this Node is a directory.
|
||||||
// This slice of will be arbitrarily deep (children, grandchildren, great-
|
// This slice of will be arbitrarily deep (children, grandchildren, great-
|
||||||
// grandchildren, etc.) if a recursive Get or Watch request were made.
|
// grandchildren, etc.) if a recursive Get or Watch request were made.
|
||||||
Nodes []*Node `json:"nodes"`
|
Nodes Nodes `json:"nodes"`
|
||||||
|
|
||||||
// CreatedIndex is the etcd index at-which this Node was created.
|
// CreatedIndex is the etcd index at-which this Node was created.
|
||||||
CreatedIndex uint64 `json:"createdIndex"`
|
CreatedIndex uint64 `json:"createdIndex"`
|
||||||
|
@ -303,6 +303,13 @@ func (n *Node) TTLDuration() time.Duration {
|
||||||
return time.Duration(n.TTL) * time.Second
|
return time.Duration(n.TTL) * time.Second
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Nodes []*Node
|
||||||
|
|
||||||
|
// interfaces for sorting
|
||||||
|
func (ns Nodes) Len() int { return len(ns) }
|
||||||
|
func (ns Nodes) Less(i, j int) bool { return ns[i].Key < ns[j].Key }
|
||||||
|
func (ns Nodes) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] }
|
||||||
|
|
||||||
type httpKeysAPI struct {
|
type httpKeysAPI struct {
|
||||||
client httpClient
|
client httpClient
|
||||||
prefix string
|
prefix string
|
||||||
|
|
Loading…
Reference in New Issue