Documentation ¶
Overview ¶
Package goflow implements a dataflow and flow-based programming library for Go.
Index ¶
- func NewDefaultGraph() interface{}
- type Annotation
- type Component
- type ComponentInfo
- type Constructor
- type Done
- type Factory
- type Graph
- func (n *Graph) Add(name string, c interface{}) error
- func (n *Graph) AddGraph(name string) error
- func (n *Graph) AddIIP(processName, portName string, data interface{}) error
- func (n *Graph) AddNew(processName string, componentName string, f *Factory) error
- func (n *Graph) Connect(senderName, senderPort, receiverName, receiverPort string) error
- func (n *Graph) ConnectBuf(senderName, senderPort, receiverName, receiverPort string, bufferSize int) error
- func (n *Graph) MapInPort(name, procName, procPort string)
- func (n *Graph) MapOutPort(name, procName, procPort string)
- func (n *Graph) Process()
- func (n *Graph) Remove(processName string) error
- func (n *Graph) RemoveIIP(processName, portName string) error
- func (n *Graph) SetInPort(name string, channel interface{}) error
- func (n *Graph) SetOutPort(name string, channel interface{}) error
- type GraphConfig
- type Message
- type PortInfo
- type Wait
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultGraph ¶
func NewDefaultGraph() interface{}
NewDefaultGraph is a ComponentConstructor for the factory.
Types ¶
type Annotation ¶
type Annotation struct { Description string // Description of what the component does Icon string // Icon name in Font Awesome used for visualization }
Annotation provides reference information about a component to graph designers and operators.
type Component ¶
type Component interface {
Process()
}
Component is a unit that can start a process.
type ComponentInfo ¶
type ComponentInfo struct { Name string `json:"name"` Description string `json:"description"` Icon string `json:"icon"` Subgraph bool `json:"subgraph"` InPorts []PortInfo `json:"inPorts"` OutPorts []PortInfo `json:"outPorts"` }
ComponentInfo represents a component to a protocol client.
type Constructor ¶
type Constructor func() (interface{}, error)
Constructor is used to create a component instance at run-time.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory registers components and creates their instances at run-time. Not safe for concurrent use.
func (*Factory) Annotate ¶
func (f *Factory) Annotate(componentName string, annotation Annotation) error
Annotate adds human-readable documentation for a component to the runtime.
func (*Factory) Create ¶
Create creates a new instance of a component registered under a specific name.
func (*Factory) Register ¶
func (f *Factory) Register(componentName string, constructor Constructor) error
Register registers a component so that it can be instantiated at run-time.
func (*Factory) Unregister ¶
Unregister removes a component with a given name from the component registry and returns true or returns false if no such component is registered.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a graph of processes connected with packet channels.
func NewGraph ¶
func NewGraph(config ...GraphConfig) *Graph
NewGraph returns a new initialized empty graph instance.
func (*Graph) AddGraph ¶
AddGraph adds a new blank graph instance to a network. That instance can be modified then at run-time.
func (*Graph) AddNew ¶
AddNew creates a new process instance using component factory and adds it to the network.
func (*Graph) Connect ¶
Connect a sender to a receiver and create a channel between them using BufferSize graph configuration. Normally such a connection is unbuffered but you can change by setting flow.DefaultBufferSize > 0 or by using ConnectBuf() function instead. It returns true on success or panics and returns false if error occurs.
func (*Graph) ConnectBuf ¶
func (n *Graph) ConnectBuf(senderName, senderPort, receiverName, receiverPort string, bufferSize int) error
ConnectBuf connects a sender to a receiver using a channel with a buffer of a given size. It returns true on success or panics and returns false if error occurs.
func (*Graph) MapInPort ¶
MapInPort adds an inport to the net and maps it to a contained proc's port.
func (*Graph) MapOutPort ¶
MapOutPort adds an outport to the net and maps it to a contained proc's port.
func (*Graph) Remove ¶
Remove deletes a process from the graph. First it stops the process if running. Then it disconnects it from other processes and removes the connections from the graph. Then it drops the process itself.
func (*Graph) SetInPort ¶
SetInPort assigns a channel to a network's inport to talk to the outer world.
func (*Graph) SetOutPort ¶
SetOutPort assigns a channel to a network's outport to talk to the outer world. It returns true on success or false if the outport cannot be set.
type GraphConfig ¶
type GraphConfig struct {
BufferSize int
}
GraphConfig sets up properties for a graph.
type Message ¶
type Message struct { // Protocol is NoFlo protocol identifier: // "runtime", "component", "graph" or "network" Protocol string `json:"protocol"` // Command is a command to be executed within the protocol Command string `json:"command"` // Payload is JSON-encoded body of the message Payload interface{} `json:"payload"` }
Message represents a single FBP protocol message.
type PortInfo ¶
type PortInfo struct { ID string `json:"id"` Type string `json:"type"` Description string `json:"description"` Addressable bool `json:"addressable"` // ignored Required bool `json:"required"` Values []interface{} `json:"values"` // ignored Default interface{} `json:"default"` // ignored }
PortInfo represents a port to a runtime client.