node_extern.go 924 B

1234567891011121314151617181920212223242526272829303132333435
  1. package store
  2. import (
  3. "time"
  4. )
  5. // NodeExtern is the external representation of the
  6. // internal node with additional fields
  7. // PrevValue is the previous value of the node
  8. // TTL is time to live in second
  9. type NodeExtern struct {
  10. Key string `json:"key, omitempty"`
  11. Value string `json:"value,omitempty"`
  12. Dir bool `json:"dir,omitempty"`
  13. Expiration *time.Time `json:"expiration,omitempty"`
  14. TTL int64 `json:"ttl,omitempty"`
  15. Nodes NodeExterns `json:"nodes,omitempty"`
  16. ModifiedIndex uint64 `json:"modifiedIndex,omitempty"`
  17. CreatedIndex uint64 `json:"createdIndex,omitempty"`
  18. }
  19. type NodeExterns []*NodeExtern
  20. // interfaces for sorting
  21. func (ns NodeExterns) Len() int {
  22. return len(ns)
  23. }
  24. func (ns NodeExterns) Less(i, j int) bool {
  25. return ns[i].Key < ns[j].Key
  26. }
  27. func (ns NodeExterns) Swap(i, j int) {
  28. ns[i], ns[j] = ns[j], ns[i]
  29. }