node_extern.go 961 B

123456789101112131415161718192021222324252627282930313233343536
  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. PrevValue string `json:"-"`
  12. Value string `json:"value,omitempty"`
  13. Dir bool `json:"dir,omitempty"`
  14. Expiration *time.Time `json:"expiration,omitempty"`
  15. TTL int64 `json:"ttl,omitempty"`
  16. Nodes NodeExterns `json:"nodes,omitempty"`
  17. ModifiedIndex uint64 `json:"modifiedIndex,omitempty"`
  18. CreatedIndex uint64 `json:"createdIndex,omitempty"`
  19. }
  20. type NodeExterns []NodeExtern
  21. // interfaces for sorting
  22. func (ns NodeExterns) Len() int {
  23. return len(ns)
  24. }
  25. func (ns NodeExterns) Less(i, j int) bool {
  26. return ns[i].Key < ns[j].Key
  27. }
  28. func (ns NodeExterns) Swap(i, j int) {
  29. ns[i], ns[j] = ns[j], ns[i]
  30. }