mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
31 lines
707 B
Go
31 lines
707 B
Go
package store
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// 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"`
|
|
}
|
|
|
|
type kvPairs []KeyValuePair
|
|
|
|
// interfaces for sorting
|
|
func (kvs kvPairs) Len() int {
|
|
return len(kvs)
|
|
}
|
|
|
|
func (kvs kvPairs) Less(i, j int) bool {
|
|
return kvs[i].Key < kvs[j].Key
|
|
}
|
|
|
|
func (kvs kvPairs) Swap(i, j int) {
|
|
kvs[i], kvs[j] = kvs[j], kvs[i]
|
|
}
|