irctree

package
v0.0.0-...-5e02a82 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PositionUnknown = iota
	PositionHub
	PositionLeaf
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	Lag     int
	Transit int
	*ServerTree
}

type Server

type Server struct {
	XMLName     xml.Name `xml:"server" json:"-"`
	ServerName  string   `xml:"servername" json:"id"`
	ParentName  string   `xml:"parentname" json:"-"`
	Label       string   `xml:"-" json:"label"`
	Lag         int      `xml:"lagmillisecs" json:"lagmillisecs"`
	Users       int      `xml:"usercount" json:"usercount"`
	Transit     int      `xml:"-" json:"-"`
	Description string   `xml:"gecos" json:"desc"`
	Position    int      `xml:"-" json:"group"`
}

Server represents the information that can be obtained about a server xml values map to those in the output of inspircd's m_httpd_stats json values map to those used in the JS vizualisation

type ServerTree

type ServerTree struct {
	Parent *Link
	Server
	Children []Link
}

ServerTree is a node from a "doubly-linked tree" (a tree where each node has both references to its parent and its children

func (*ServerTree) GetList

func (t *ServerTree) GetList() []Server

GetList is a utility function to return an easily iterable version of the tree

type Servers

type Servers struct {
	Root   *ServerTree
	Lookup map[string]*ServerTree
}

Servers is a helper structure to quickly iterate (in no particular order) on the contents of a ServerTree

func BuildTree

func BuildTree(ircmap []Server) (s *Servers)

BuildTree constructs a Servers abstraction from a list of Server

func (*Servers) Add

func (s *Servers) Add(node *Server) error

Add a server to an existing tree

func (*Servers) Normalize

func (s *Servers) Normalize() *Servers

Normalize finds a better root than the current one and shifts to there, if it exists ! Normalize destroys transit information

func (Servers) Slice

func (s Servers) Slice() []Server

Slice is GetList for the Servers abstraction

func (*Servers) String

func (s *Servers) String() string

String returns an ascii human-readable representation of the tree

Jump to

Keyboard shortcuts

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