Documentation ¶
Index ¶
- func FindFs(name string) (fs.FS, bool)
- func RegisterFs(name string, fsys fs.FS) error
- func RegisterNode(name string, newfunc NewNodeFunc) error
- func RunNode(node Node, input RunInput, output *RunOutput) error
- type ClonePolicy
- type Cloner
- type ContentData
- type Flusher
- type NewNodeFunc
- type Node
- type Pin
- type Pipeline
- type RunInput
- type RunOutput
- type Runner
- type StartInput
- type Starter
- type State
- type StructData
- type StructField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterFs ¶
RegisterFs adds a named file system to the registry. Nodes can make use of named filesystem for, example, in loading operations.
func RegisterNode ¶
func RegisterNode(name string, newfunc NewNodeFunc) error
Types ¶
type ClonePolicy ¶
type ClonePolicy int
const ( SmartClone ClonePolicy = iota // A clone is made when one payload is going to two ore more RunInputs, othwerwise no clone. AlwaysClone // A clone is always made. NeverClone // A clone is never made. )
type ContentData ¶
ContentData provides a generic content string.
func (*ContentData) Clone ¶
func (d *ContentData) Clone() Cloner
type Flusher ¶
type Flusher interface { // Flush any data in the node. // There's no reason to reallocate or replace the RunOutput.Pins, // just append to what's there. Flush(*State, *RunOutput) error }
Flusher implements a flush operation.
type NewNodeFunc ¶
type NewNodeFunc func() Node
type Node ¶
type Node interface { Runner }
Node is a single function in the pipeline graph. It runs an operation on some input, optionally providing some output.
Node implementations should be thread-safe. The framework uses a NodeData pattern to accomplish this in a simple way: Nodes have a parallel NodeData struct that stores their data. A node anonymously includes its NodeData, and also sets it to State.NodeData in the Start() func. THe data is then passed back in State.Node data during the Run() and Flush().
Optional interfaces: * Starter * Flusher
type Pin ¶
type Pin struct { Name string Payload Cloner Policy ClonePolicy }
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
type RunInput ¶
type RunInput struct {
Pins []Pin
}
RunInput transports pin data into a Run function.
func NewRunInput ¶
NewRunInput answers a new RunInput on the given pins.
func (RunInput) NewRunOutput ¶
NewRunOutput answers a new RunOutput on the given pins.
type RunOutput ¶
type RunOutput struct {
Pins []Pin
}
RunOutput transports pin data out of a Run function.
type Runner ¶
type Runner interface { // Run the supplied pins, converting the input to output. // There's no reason to reallocate or replace the RunOutput.Pins, // just append to what's there. Run(*State, RunInput, *RunOutput) error }
Runner processes input.
type StartInput ¶
type StartInput interface {
SetNodeData(any)
}
type Starter ¶
type Starter interface { // One-time notification that the node is starting a run. // Clients that want to use the NodeData pattern can assign // the NodeData field and it will be available during the Run. Start(StartInput) error }
Starter is called at the start of a pipeline run. Implementing starter, and placing all run state in a node data object, will make your node thread-safe.
type State ¶
type State struct { // The data set in Starter.Start. NodeData any }
State provides current state data to a running node.
type StructData ¶
type StructData struct { // The name of the source struct. Name string // All exported fields in the struct. Fields []StructField // All unexported fields in the struct. It should be rare // for a client to want access to these fields, so we keep // them in a separate slice to avoid polluting the fields list. UnexportedFields []StructField }
StructData provides information about a single struct from source data.
func NewStructData ¶
func NewStructData(name string, fields []StructField, unexportedFields []StructField) *StructData
func (*StructData) Clone ¶
func (d *StructData) Clone() Cloner