tree

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: Unlicense Imports: 4 Imported by: 6

README

go-tree

Guidelines

  • AddChild panics if node is closed or child name is taken.
  • Processes are not closed when their node closes but they do close their node on exit.
  • Children are closed asynchronously in a go routine different from the one calling their parent close.
  • Children autoremove from parent but do not close parent.
  • Children that need to auto close their parent must explicitly add a closer pointing to their parent.
  • Use IfRecoverX to ensure close of resources when add child or add process panics

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node interface {
	Name() string
	State() *State
	AddChild(name string) Node
	GetValue(name string) interface{}
	SetValue(name string, value interface{})
	AddProcess(name string, action func())
	AddAction(name string, action func())
	AddCloser(name string, action func() error)
	AddChannel(name string, channel chan interface{})
	IfRecoverAction(action func())
	IfRecoverCloser(action func() error)
	IfRecoverChannel(channel chan interface{})
	Disposed() <-chan interface{}
	Closed() <-chan interface{}
	Println(args ...interface{})
	PanicIfError(err error)
	WaitDisposed()
	WaitClosed()
	Recover()
	Close()
}

func NewRoot

func NewRoot(name string, log func(args ...interface{})) Node

type Reversed

type Reversed interface {
	Count() int
	Names() []string
	Values() []interface{}
	Get(string) interface{}
	Set(string, interface{})
	Remove(string) interface{}
}

func NewReversed

func NewReversed() Reversed

type State

type State struct {
	Name      string
	Values    map[string]string
	Actions   []string
	Processes []string
	Children  []Node
	Closed    bool
	Disposed  bool
}

Jump to

Keyboard shortcuts

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