xtree

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// XStatusUp XNode is up
	XStatusUp XStatus = "up"
	// XStatusDown XNode is down
	XStatusDown = "down"
	// XStatusDegraded XNode parent is down
	XStatusDegraded = "degraded"
)

Variables

View Source
var (
	// ErrWalkAbort error returned to stop tree walk
	ErrWalkAbort = errors.New("abort XTree walk")
	// ErrXNodeNotFound error returned when XNode is not found
	ErrXNodeNotFound = errors.New("XNode not found in the XTree")
)

Functions

This section is empty.

Types

type XNode

type XNode interface {
	// UUID unique identifier for this node.
	UUID() string
	// Equals returns true if node is equal to this XNode
	Equals(node XNode) bool
	// Parents of this node, a node can be present multiple times in the tree.
	Parents() []XNode
	// IsParent return true if this node is parent of specified XNode
	IsParent(node XNode) bool
	// Children list of child XNodes
	Children() []XNode
	// AddChildren adds list of nodes to the list of children
	AddChildren(node []XNode)
	// AddParent to the list of parents.
	AddParent(node XNode)
	// RemoveParent from the list of parents
	RemoveParent(node XNode) error
	// RemoveChild from the list of children
	RemoveChild(node XNode) error
	// AddLink adds a link to another XNode
	AddLink(link XNode)
	// RemoveLink to XNode
	RemoveLink(link XNode) error
	// HasLink returns true if this node has a link to specified XNode
	HasLink(link XNode) bool
	// Walk tree beginning from this XNode
	Walk(cb XNodeIteratorCB) error
	// WalkToRoot iterate to root
	WalkToRoot(cb XNodeIteratorCB) error
	// MarkDown mark this XNode as down
	MarkDown()
	// MarkUp mark this XNode as up.
	MarkUp()
	// Status return status of xnode evaluating status of the parents as well.
	Status() XStatus
	// LocalStatus return local status of this XNode
	LocalStatus() XStatus
	// Data returns the user data stored in this xnode
	Data() interface{}
	// contains filtered or unexported methods
}

XNode designates a node in XTree

func NewXNode

func NewXNode(uuid string, data interface{}) XNode

NewXNode creates XNode with specified uuid

type XNodeIteratorCB

type XNodeIteratorCB func(xnode XNode) error

XNodeIteratorCB iterator callback for tree walk. If an error is returned, the walk is aborted.

type XStatus

type XStatus string

XStatus status of an XNode

type XTree

type XTree interface {
	// Root of the xtree
	Root() XNode
	// Find returns XNode with matching UUID
	Find(uuid string) (XNode, error)
	// FindLinked returns XNodes that are linked to specified link.
	FindLinked(link XNode) ([]XNode, error)
	// SetLink links link to specified XNodes. It removes link from nodes
	// that are not in the linked list.
	SetLink(link XNode, linked []XNode) error
	// RemoveLink from all linked nodes.
	RemoveLink(link XNode) error
	// Insert XNode into the tree
	Insert(node XNode, parentUUIDs []string) error
	// Remove XNode and its children
	Remove(node XNode) error
}

XTree represents a n-ary tree or XNodes

func NewXTree

func NewXTree(uuid string, data interface{}) XTree

NewXTree creates XTree with specified uuid as root

Jump to

Keyboard shortcuts

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