forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_extern.go
36 lines (30 loc) · 961 Bytes
/
node_extern.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package store
import (
"time"
)
// NodeExtern is the external representation of the
// internal node with additional fields
// PrevValue is the previous value of the node
// TTL is time to live in second
type NodeExtern struct {
Key string `json:"key, omitempty"`
PrevValue string `json:"-"`
Value string `json:"value,omitempty"`
Dir bool `json:"dir,omitempty"`
Expiration *time.Time `json:"expiration,omitempty"`
TTL int64 `json:"ttl,omitempty"`
Nodes NodeExterns `json:"nodes,omitempty"`
ModifiedIndex uint64 `json:"modifiedIndex,omitempty"`
CreatedIndex uint64 `json:"createdIndex,omitempty"`
}
type NodeExterns []NodeExtern
// interfaces for sorting
func (ns NodeExterns) Len() int {
return len(ns)
}
func (ns NodeExterns) Less(i, j int) bool {
return ns[i].Key < ns[j].Key
}
func (ns NodeExterns) Swap(i, j int) {
ns[i], ns[j] = ns[j], ns[i]
}