glow

package module
v0.0.0-...-7ccfc1d Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

Computational Network Framework

GoDoc Go Report Card

The Glow is an idiomatic computational network framework.

Examples

Examples

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func DOT

func DOT(n *Network) ([]byte, error)

DOT describes the Network.

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 Link struct {
	X string
	Y string
	// contains filtered or unexported fields
}

Link captures connection between two nodes. Data flows from x to y over the Link.

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 (n *Network) AddLink(from, to string, size int) error

AddLink connects from node and to nodes. Once Link is made, nodes are said to be communicated over Link channel.

func (*Network) AddNode

func (n *Network) AddNode(node Node) (string, error)

AddNode adds a new Node in the network. Node key is retrieved from the provided Key function.

func (*Network) Egress

func (n *Network) Egress(k string) []*Link

Egress returns all the egress links for the Node.

func (*Network) Ingress

func (n *Network) Ingress(k string) []*Link

Ingress returns all the ingress links for the Node.

func (n *Network) Link(from, to string) (*Link, error)

Link returns connection between from and to nodes if any.

func (n *Network) Links() []*Link

Links returns all the links in the Network.

func (*Network) Node

func (n *Network) Node(k string) (Node, error)

Node returns the node identified by the provided key.

func (*Network) Nodes

func (n *Network) Nodes() []string

Nodes returns all the nodes as their unique keys in the network. Node should be called to get actual node.

func (n *Network) RemoveLink(from, to string) error

RemoveLink disconnects from node and to node. Underlying communication channel is closed.

func (*Network) RemoveNode

func (n *Network) RemoveNode(k string) error

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

func (n *Network) Seeds() []string

Seeds returns all the nodes that have only egress links. Node should be called to get actual node.

func (*Network) Start

func (n *Network) Start() error

Start runs the Network.

func (*Network) Stop

func (n *Network) Stop() error

Stop stops the Network. Once Network stops, all communications are seized.

func (*Network) Termini

func (n *Network) Termini() []string

Termini returns all the nodes that have only ingress 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

type Node

type Node func(context.Context, []byte) ([]byte, error)

Node defines a node in the Network. Node is said to be Seed node if it has only egress Links. Node is said to be Terminus node if it has only ingress Links.

Jump to

Keyboard shortcuts

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