const CompareMatch … const CompareIndexNotMatch … const CompareValueNotMatch … const CompareNotMatch … var Permanent … type node … // newKV creates a Key-Value pair func newKV(store *store, nodePath string, value string, createdIndex uint64, parent *node, expireTime time.Time) *node { … } // newDir creates a directory func newDir(store *store, nodePath string, createdIndex uint64, parent *node, expireTime time.Time) *node { … } // IsHidden function checks if the node is a hidden node. A hidden node // will begin with '_' // A hidden node will not be shown via get command under a directory // For example if we have /foo/_hidden and /foo/notHidden, get "/foo" // will only return /foo/notHidden func (n *node) IsHidden() bool { … } // IsPermanent function checks if the node is a permanent one. func (n *node) IsPermanent() bool { … } // IsDir function checks whether the node is a directory. // If the node is a directory, the function will return true. // Otherwise the function will return false. func (n *node) IsDir() bool { … } // Read function gets the value of the node. // If the receiver node is not a key-value pair, a "Not A File" error will be returned. func (n *node) Read() (string, *v2error.Error) { … } // Write function set the value of the node to the given value. // If the receiver node is a directory, a "Not A File" error will be returned. func (n *node) Write(value string, index uint64) *v2error.Error { … } func (n *node) expirationAndTTL(clock clockwork.Clock) (*time.Time, int64) { … } // List function return a slice of nodes under the receiver node. // If the receiver node is not a directory, a "Not A Directory" error will be returned. func (n *node) List() ([]*node, *v2error.Error) { … } // GetChild function returns the child node under the directory node. // On success, it returns the file node func (n *node) GetChild(name string) (*node, *v2error.Error) { … } // Add function adds a node to the receiver node. // If the receiver is not a directory, a "Not A Directory" error will be returned. // If there is an existing node with the same name under the directory, a "Already Exist" // error will be returned func (n *node) Add(child *node) *v2error.Error { … } // Remove function remove the node. func (n *node) Remove(dir, recursive bool, callback func(path string)) *v2error.Error { … } func (n *node) Repr(recursive, sorted bool, clock clockwork.Clock) *NodeExtern { … } func (n *node) UpdateTTL(expireTime time.Time) { … } // Compare function compares node index and value with provided ones. // second result value explains result and equals to one of Compare.. constants func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) { … } // Clone function clone the node recursively and return the new node. // If the node is a directory, it will clone all the content under this directory. // If the node is a key-value pair, it will clone the pair. func (n *node) Clone() *node { … } // recoverAndclean function help to do recovery. // Two things need to be done: 1. recovery structure; 2. delete expired nodes // // If the node is a directory, it will help recover children's parent pointer and recursively // call this function on its children. // We check the expire last since we need to recover the whole structure first and add all the // notifications into the event history. func (n *node) recoverAndclean() { … }