github.com/kula/etcd@v0.2.1-0.20131226070625-e96234382ac0/store/node_extern.go (about)

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