Documentation ¶
Index ¶
- Variables
- func DOT(n *Network) ([]byte, error)
- type Key
- type Link
- type Network
- func (n *Network) AddLink(from, to string, size int) error
- func (n *Network) AddNode(node Node) (string, error)
- func (n *Network) Egress(k string) []*Link
- func (n *Network) Ingress(k string) []*Link
- func (n *Network) Link(from, to string) (*Link, error)
- func (n *Network) Links() []*Link
- func (n *Network) Node(k string) (Node, error)
- func (n *Network) Nodes() []string
- func (n *Network) RemoveLink(from, to string) error
- func (n *Network) RemoveNode(k string) error
- func (n *Network) Seeds() []string
- func (n *Network) Start() error
- func (n *Network) Stop() error
- func (n *Network) Termini() []string
- type NetworkOpt
- type Node
Constants ¶
This section is empty.
Variables ¶
var ( ErrNodeNotFound = errors.New("node not found") ErrNodeAlreadyExists = errors.New("node already exists") ErrLinkNotFound = errors.New("link not found") ErrLinkAlreadyExists = errors.New("link already exists") ErrNodeIsConnected = errors.New("node is connected") ErrEmptyNetwork = errors.New("network is empty") ErrSeedingDone = errors.New("seeding is done") ErrUnlinkedNodeFound = errors.New("unlinked node found") )
Functions ¶
Types ¶
type Key ¶
type Key func() string
Key returns a value of type K that is used to generate unique keys for the nodes in the Network.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network represents nodes and their links.
func New ¶
func New(key Key, opt ...NetworkOpt) *Network
New creates a new Network. Provided Key function is used to get unique keys for the nodes.
func (*Network) AddLink ¶
AddLink connects from node and to nodes. Once Link is made, nodes are said to be communicated over Link channel.
func (*Network) AddNode ¶
AddNode adds a new Node in the network. Node key is retrieved from the provided Key function.
func (*Network) Nodes ¶
Nodes returns all the nodes as their unique keys in the network. Node should be called to get actual node.
func (*Network) RemoveLink ¶
RemoveLink disconnects from node and to node. Underlying communication channel is closed.
func (*Network) RemoveNode ¶
RemoveNode removes a node with provided key. A node can't be removed if it is connected/linked to any other node in the network.
func (*Network) Seeds ¶
Seeds returns all the nodes that have only egress links. Node should be called to get actual node.
type NetworkOpt ¶
type NetworkOpt func(*networkOpts)
func StopGracetime ¶
func StopGracetime(t time.Duration) NetworkOpt
func Verbose ¶
func Verbose() NetworkOpt