*: reflow comments to 80 characters
This reformats the entire Metropolis codebase to have comments no longer
than 80 characters, implementing CR/66.
This has been done half manually, as we don't have a good integration
between commentwrap/Bazel, but that can be implemented if we decide to
go for this tool/limit.
Change-Id: If1fff0b093ef806f5dc00551c11506e8290379d0
diff --git a/metropolis/pkg/logtree/logtree.go b/metropolis/pkg/logtree/logtree.go
index a21545f..968a5a9 100644
--- a/metropolis/pkg/logtree/logtree.go
+++ b/metropolis/pkg/logtree/logtree.go
@@ -24,12 +24,13 @@
"source.monogon.dev/metropolis/pkg/logbuffer"
)
-// LogTree is a tree-shaped logging system. For more information, see the package-level documentation.
+// LogTree is a tree-shaped logging system. For more information, see the package-
+// level documentation.
type LogTree struct {
// journal is the tree's journal, storing all log data and managing subscribers.
journal *journal
- // root is the root node of the actual tree of the log tree. The nodes contain per-DN configuration options, notably
- // the current verbosity level of that DN.
+ // root is the root node of the actual tree of the log tree. The nodes contain per-
+ // DN configuration options, notably the current verbosity level of that DN.
root *node
}
@@ -41,25 +42,29 @@
return lt
}
-// node represents a given DN as a discrete 'logger'. It implements the LeveledLogger interface for log publishing,
-// entries from which it passes over to the logtree's journal.
+// node represents a given DN as a discrete 'logger'. It implements the
+// LeveledLogger interface for log publishing, entries from which it passes over to
+// the logtree's journal.
type node struct {
// dn is the DN which this node represents (or "" if this is the root node).
dn DN
// tree is the LogTree to which this node belongs.
tree *LogTree
- // verbosity is the current verbosity level of this DN/node, affecting .V(n) LeveledLogger calls
+ // verbosity is the current verbosity level of this DN/node, affecting .V(n)
+ // LeveledLogger calls
verbosity VerbosityLevel
rawLineBuffer *logbuffer.LineBuffer
// mu guards children.
mu sync.Mutex
- // children is a map of DN-part to a children node in the logtree. A DN-part is a string representing a part of the
- // DN between the deliming dots, as returned by DN.Path.
+ // children is a map of DN-part to a children node in the logtree. A DN-part is a
+ // string representing a part of the DN between the deliming dots, as returned by
+ // DN.Path.
children map[string]*node
}
-// newNode returns a node at a given DN in the LogTree - but doesn't set up the LogTree to insert it accordingly.
+// newNode returns a node at a given DN in the LogTree - but doesn't set up the
+// LogTree to insert it accordingly.
func newNode(tree *LogTree, dn DN) *node {
n := &node{
dn: dn,
@@ -72,8 +77,8 @@
return n
}
-// nodeByDN returns the LogTree node corresponding to a given DN. If either the node or some of its parents do not
-// exist they will be created as needed.
+// nodeByDN returns the LogTree node corresponding to a given DN. If either the
+// node or some of its parents do not exist they will be created as needed.
func (l *LogTree) nodeByDN(dn DN) (*node, error) {
traversal, err := newTraversal(dn)
if err != nil {
@@ -82,22 +87,27 @@
return traversal.execute(l.root), nil
}
-// nodeTraversal represents a request to traverse the LogTree in search of a given node by DN.
+// nodeTraversal represents a request to traverse the LogTree in search of a given
+// node by DN.
type nodeTraversal struct {
// want is the DN of the node's that requested to be found.
want DN
- // current is the path already taken to find the node, in the form of DN parts. It starts out as want.Parts() and
- // progresses to become empty as the traversal continues.
+ // current is the path already taken to find the node, in the form of DN parts. It
+ // starts out as want.Parts() and progresses to become empty as the traversal
+ // continues.
current []string
- // left is the path that's still needed to be taken in order to find the node, in the form of DN parts. It starts
- // out empty and progresses to become wants.Parts() as the traversal continues.
+ // left is the path that's still needed to be taken in order to find the node, in
+ // the form of DN parts. It starts out empty and progresses to become wants.Parts()
+ // as the traversal continues.
left []string
}
-// next adjusts the traversal's current/left slices to the next element of the traversal, returns the part that's now
-// being looked for (or "" if the traveral is done) and the full DN of the element that's being looked for.
+// next adjusts the traversal's current/left slices to the next element of the
+// traversal, returns the part that's now being looked for (or "" if the traveral
+// is done) and the full DN of the element that's being looked for.
//
-// For example, a traversal of foo.bar.baz will cause .next() to return the following on each invocation:
+// For example, a traversal of foo.bar.baz will cause .next() to return the
+// following on each invocation:
// - part: foo, full: foo
// - part: bar, full: foo.bar
// - part: baz, full: foo.bar.baz
@@ -125,9 +135,10 @@
}, nil
}
-// execute the traversal in order to find the node. This can only be called once per traversal.
-// Nodes will be created within the tree until the target node is reached. Existing nodes will be reused.
-// This is effectively an idempotent way of accessing a node in the tree based on a traversal.
+// execute the traversal in order to find the node. This can only be called once
+// per traversal. Nodes will be created within the tree until the target node is
+// reached. Existing nodes will be reused. This is effectively an idempotent way of
+// accessing a node in the tree based on a traversal.
func (t *nodeTraversal) execute(n *node) *node {
cur := n
for {