Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRecording ¶
IsRecording indicates whether a recording involving a given node is currently in progress. Can be used as a fast check before calling StartOpf.
func NodeUpdated ¶
NodeUpdated can be used to trigger a new step in any recording that involves the given node. It can be used when the state of the node changed in a significant way. The reason is optional and will show up in the step description.
func TreeToString ¶
TreeToString returns a string representation of the current state of a Node tree.
Types ¶
type Node ¶
type Node interface {
TreeStepsNode() NodeInfo
}
Node must be implemnented by every node in the hierarchy.
type NodeInfo ¶
type NodeInfo struct {
// contains filtered or unexported fields
}
NodeInfo contains the information that we present for each node.
func (*NodeInfo) AddChildren ¶
AddChildren adds one or more children to the NodeInfo.
Any nil children are ignored (this includes nil pointers of any type).
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op represents an operation that is associated with a node.
func StartOpf ¶
StartOpf registers the start of a new operation on a node and emits a step. The operation will be displayed for the given node until FinishOpf is called.
If a recording involving the node is not currently in progress, does nothing and returns nil. Other methods can be called (and do nothing) when Op is nil.
Note: it is recommended that IsRecording() is checked first to avoid any allocations (e.g. due to boxing of args) in the normal, non-recording path.
type Recording ¶
type Recording struct {
// contains filtered or unexported fields
}
Recording captures the step-by-step propagation of operations. See StartRecording.
func StartRecording ¶
func StartRecording(root Node, name string, opts ...RecordingOption) *Recording
StartRecording starts a new recording that captures step-by-step propagation of operations and changes in a hierarchical structure.
Each node in the structure must implement the TreeStepsNode method, which returns information about the current state of the node and a list of its children. For every operation or sub-operation on a node, StartOpf and FinishOpf must be called. Calling Finish() on the Recording will return all the collected information (which can be presented as text or as a link to a visualization).
It is not legal to start a recording that involves the same node as another in-progress recording (this applies to all nodes in the hierarchy).
See SegmentTree in tree_steps_test.go for an example.
type RecordingOption ¶
type RecordingOption func(*Recording)
RecordingOption is an optional argument to StartRecording.
func MaxOpDepth ¶
func MaxOpDepth(maxOpDepth int) RecordingOption
MaxOpDepth configures a recording to only show operations for nodes up to a certain depth. Operations and node updates below that level are ignored.
func MaxTreeDepth ¶
func MaxTreeDepth(maxTreeDepth int) RecordingOption
MaxTreeDepth configures a recording to only show trees up to a certain depth. Operations and node updates below that level are ignored.