graph

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package graph works on top of the node package and provides a Domain-Specific Language for a flexible definition of node graphs and their interconnections. Deprecated package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCodec

func RegisterCodec[I, O any](nb *Builder, middleFunc node.MiddleFunc[I, O])

RegisterCodec registers a Codec into the graph builder. A Codec is a node.MiddleFunc provider that allows converting data types and it's automatically inserted when a node with a given output type is connected to a node with a different input type. When nodes with different types are connected, a codec converting between both MUST have been registered previously. Otherwise the graph Build method will fail. Deprecated package. Use github.com/mariomac/pipes/pipe package

func RegisterMiddle

func RegisterMiddle[CFG, I, O any](nb *Builder, b stage.MiddleProvider[CFG, I, O])

RegisterMiddle registers a stage.MiddleProvider into the graph builder. When the Build method is invoked later, any configuration field associated with the MiddleProvider will result in the instantiation of a node.Middle with the provider's returned provider. The passed configuration type must either implement the stage.Instancer interface or the configuration struct containing it must define a `nodeId` tag with an identifier for that stage. Deprecated. Please use the low-level API of this library as this will be removed in future versions. Deprecated package. Use github.com/mariomac/pipes/pipe package

func RegisterMiddleDemux added in v0.9.0

func RegisterMiddleDemux[CFG, I any](nb *Builder, b stage.MiddleDemuxProvider[CFG, I])

RegisterMiddleDemux registers a stage.MiddleDemuxProvider into the graph builder. When the Build method is invoked later, any configuration field associated with the MiddleProvider will result in the instantiation of a node.MiddleDemux with the provider's returned provider. The passed configuration type must either implement the stage.Instancer interface or the configuration struct containing it must define a `nodeId` tag with an identifier for that stage. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

func RegisterMultiStart added in v0.6.0

func RegisterMultiStart[CFG, O any](nb *Builder, b stage.StartMultiProvider[CFG, O])

RegisterMultiStart is similar to RegisterStart, but registers a stage.StartMultiProvider, which allows associating multiple functions with a single node Deprecated. Please use the low-level API of this library as this will be removed in future versions. Deprecated package. Use github.com/mariomac/pipes/pipe package

func RegisterStart

func RegisterStart[CFG, O any](nb *Builder, b stage.StartProvider[CFG, O])

RegisterStart registers a stage.StartProvider into the graph builder. When the Build method is invoked later, any configuration field associated with the StartProvider will result in the instantiation of a node.Start with the provider's returned provider. The passed configuration type must either implement the stage.Instancer interface or the configuration struct containing it must define a `nodeId` tag with an identifier for that stage. Deprecated. Please use the low-level API of this library as this will be removed in future versions. Deprecated package. Use github.com/mariomac/pipes/pipe package

func RegisterStartDemux added in v0.9.0

func RegisterStartDemux[CFG any](nb *Builder, b stage.StartDemuxProvider[CFG])

RegisterStartDemux registers a stage.StartDemuxProvider into the graph builder. When the Build method is invoked later, any configuration field associated with the StartProvider will result in the instantiation of a node.StartDemux with the provider's returned provider. The passed configuration type must either implement the stage.Instancer interface or the configuration struct containing it must define a `nodeId` tag with an identifier for that stage. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

func RegisterTerminal

func RegisterTerminal[CFG, I any](nb *Builder, b stage.TerminalProvider[CFG, I])

RegisterTerminal registers a stage.TerminalProvider into the graph builder. When the Build method is invoked later, any configuration field associated with the TerminalProvider will result in the instantiation of a node.Terminal with the provider's returned provider. The passed configuration type must either implement the stage.Instancer interface or the configuration struct containing it must define a `nodeId` tag with an identifier for that stage. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder helps to build a graph and to connect their nodes. It takes care of instantiating all its stages given a name and a type, as well as connect them. If two connected stages have incompatible types, it will insert a codec in between to translate between the stage types deprecated type. To be removed in future versions: use the low-level API.

func NewBuilder

func NewBuilder(options ...node.Option) *Builder

NewBuilder instantiates a Graph Builder with the default configuration, which can be overridden via the arguments. Deprecated. Please use the low-level API of this library as this will be removed in future versions. Deprecated package. Use github.com/mariomac/pipes/pipe package

func (*Builder) Build

func (nb *Builder) Build(cfg any) (Graph, error)

Build creates a Graph where each node corresponds to a field in the provided Configuration struct. The nodes will be connected according to any of the following alternatives:

  • The ConnectedConfig "source" --> ["destination"...] map, if the passed type implements ConnectedConfig interface.
  • The sendTo annotations on each graph stage.

Deprecated. Please use the low-level API of this library as this will be removed in future versions.

type ConnectedConfig

type ConnectedConfig interface {
	// Connections returns a map representing the connection of the node graphs, where
	// the key contains the instance ID of the source node, and the value contains an
	// array of the destination nodes' instance IDs.
	Connections() map[string][]string
}

ConnectedConfig describes the interface that any struct passed to the builder.Build method must fullfill. Consider embedding the Connector type into your struct for automatic implementation of the interface. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

type Connector

type Connector map[string][]string

Connector is a convenience implementor of the ConnectedConfig interface, required to build any graph. It can be embedded into any configuration struct that is passed as argument into the builder.Build method.

Key: instance ID of the source node. Value: array of destination node instance IDs. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

func (Connector) Connections

func (c Connector) Connections() map[string][]string

Connections returns the connection map represented by the Connector

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph is set of Start Nodes that generate information that is forwarded to Middle or Terminal nodes, which process that information. It must be created from the Builder type. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

func (*Graph) Run

func (g *Graph) Run()

Run all the stages of the graph and wait until all the nodes stopped processing. Deprecated. Please use the low-level API of this library as this will be removed in future versions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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