Documentation
¶
Index ¶
- func RegisterCodec[I, O any](nb *Builder, middleFunc node.MiddleFunc[I, O])
- func RegisterMiddle[CFG, I, O any](nb *Builder, b stage.MiddleProvider[CFG, I, O])
- func RegisterMiddleDemux[CFG, I any](nb *Builder, b stage.MiddleDemuxProvider[CFG, I])
- func RegisterMultiStart[CFG, O any](nb *Builder, b stage.StartMultiProvider[CFG, O])
- func RegisterStart[CFG, O any](nb *Builder, b stage.StartProvider[CFG, O])
- func RegisterStartDemux[CFG any](nb *Builder, b stage.StartDemuxProvider[CFG])
- func RegisterTerminal[CFG, I any](nb *Builder, b stage.TerminalProvider[CFG, I])
- type Builder
- type ConnectedConfig
- type Connector
- type Graph
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.
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.
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.
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
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.
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.
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.
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
func NewBuilder ¶
NewBuilder instantiates a Graph Builder with the default configuration, which can be overridden via the arguments.
func (*Builder) Build ¶
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.
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.
type Connector ¶
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.
func (Connector) Connections ¶
Connections returns the connection map represented by the Connector