Documentation ¶
Overview ¶
Package journalspace provides mechanisms for mapping a collection of JournalSpecs into a minimally-described hierarchical structure, and for mapping back again. This is principally useful for tooling over JournalSpecs, which must be written to (& read from) Etcd in fully-specified and explicit form (a representation which is great for implementors, but rather tedious for cluster operators to work with). Tooling can map JournalSpecs into a tree, allow the operator to apply edits in that hierarchical space, and then flatten resulting changes for storage back to Etcd.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { // JournalSpec of the Node, which may be partial and incomplete. Specs apply // hierarchically, where Nodes having zero-valued fields inherit those of // their parent, and parent Nodes may only have a subset of fields specified. // A Node is understood to be a "directory" Node if it ends in a slash '/', // and a literal or terminal Node otherwise. pb.JournalSpec `yaml:",omitempty,inline"` // Delete marks that a Node, and all Nodes which it parents, should be deleted. Delete bool `yaml:",omitempty"` // Revision of the Journal within Etcd. Non-zero for non-directory Nodes only. Revision int64 `yaml:",omitempty"` // Children of this Node. Directory Nodes must have one or more Children, and // non-directory terminal Nodes may not have any. Children []Node `yaml:",omitempty"` }
Node represents a collection of JournalSpecs which are related by hierarchical path components, and which may share common portions of their journal specifications.
func ExtractTree ¶
ExtractTree derives the tree from ordered []Nodes implied by their shared path "directories", or component prefixes. For example, journals:
- root/foo/bar
- root/foo/baz
- root/bing
Will result in the tree:
- root/
- root/foo/
- root/foo/bar
- root/foo/baz
- root/bing
func (*Node) Flatten ¶
Flatten indirect and direct children of the Node into a Node slice, merging parent JournalSpecs into those of children at each descending level of the hierarchy.
func (*Node) HoistSpecs ¶
func (n *Node) HoistSpecs()
HoistSpecs performs a bottom-up initialization of non-terminal "directory" Node JournalSpec fields. Specifically, at each recursive step a parent Node specification field is set if the value is shared by all of the Node's direct Children. The field is then zeroed at each child in turn. After hoisting, the overall repetition of JournalSpec fields in the tree is minimized, as every field which is already implied by a parent is zeroed.
func (Node) IsDir ¶
IsDir returns whether the Node.JournalSpec.Name is empty or ends in a slash ('/').