tftree

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRootDoesNotExist = fmt.Errorf("SetRoot can only be used on nodes in the tree")

Functions

func CopySpan

func CopySpan(span *model.Span) (*model.Span, error)

Types

type SpanTree

type SpanTree struct {
	Root *model.Span
	// contains filtered or unexported fields
}

func NewSpanTree

func NewSpanTree(spans []*model.Span) *SpanTree

func (*SpanTree) Add

func (tree *SpanTree) Add(newSpan *model.Span, parentId model.SpanID)

Adds a span as a child of another.

parentId must not be exited yet (and may or may not be entered).

func (*SpanTree) AddTree

func (tree *SpanTree) AddTree(childTree *SpanTree, parentId model.SpanID)

Adds all spans in a tree as a subtree in this span.

TODO FIXME: when the two trees have overlapping span IDs, this does not work correctly.

func (*SpanTree) Children

func (tree *SpanTree) Children(id model.SpanID) map[model.SpanID]struct{}

func (*SpanTree) Clone

func (tree *SpanTree) Clone() (*SpanTree, error)

func (*SpanTree) Delete

func (tree *SpanTree) Delete(spanId model.SpanID)

Deletes a span entirely from the tree.

All remaining children also get deleted from the list of spans. Can only be called when entering/exiting spanId or entering its parents (i.e. deleting descendents). Cannot be used to delete the root span. TreeVisitor.Exit will not be called if Delete is called during enter.

func (*SpanTree) GetSpans

func (tree *SpanTree) GetSpans() []*model.Span

func (*SpanTree) Move

func (tree *SpanTree) Move(movedSpanId model.SpanID, newParentId model.SpanID)

Moves a span from one span to another.

movedSpan must not be entered yet. newParent must not be exited yet (and may or may not be entered).

func (*SpanTree) SetRoot

func (tree *SpanTree) SetRoot(id model.SpanID) error

Sets the root to a span under the current root, and prunes other spans not under the new root.

func (*SpanTree) Span

func (tree *SpanTree) Span(id model.SpanID) *model.Span

func (*SpanTree) Visit

func (tree *SpanTree) Visit(visitor TreeVisitor)

type TreeVisitor

type TreeVisitor interface {
	// Called before entering the descendents of the span.
	//
	// This method may call tree.Add, tree.Move and tree.Delete
	// with the ancestors of span, span itself and its descendents.
	Enter(tree *SpanTree, span *model.Span) TreeVisitor
	// Called after exiting the descendents of the span.
	Exit(tree *SpanTree, span *model.Span)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL