Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorsEqual(a, b error) bool
- func MergeErrors(err ...error) error
- func NewBadRequestError(msg string) error
- func NewIllegalError(msg string) error
- func NewMissingError(msg string) error
- func NewParseError(err error) error
- func Register(fac NodeFactory) error
- func RegisterVar(name, descr string, optional_value interface{})
- func StringPinsEqual(a, b Pins) bool
- func StringPinsToJson(pins Pins) string
- func WalkItems(pins Pins, channel string, fn ItemFunc)
- func WalkStringItems(pins Pins, channel string, fn StringItemFunc)
- type BuildPinsCmd
- type CfgDescr
- type Doc
- type Docs
- type Environment
- type Header
- type InstantiateArgs
- type ItemFunc
- type Items
- type Msg
- type Node
- type NodeDescr
- type NodeFactory
- type NodeOutput
- type NodeStage
- type PhlyError
- type PinBuilder
- type PinDescr
- type Pins
- type PinsWalkFunc
- type Pipeline
- type ProcessArgs
- type SortNodeFactory
- type SortVars
- type StartArgs
- type StopPayload
- type StoppedArgs
- type StringItemFunc
Constants ¶
const ( BadRequestErrCode = 1000 + iota IllegalErrCode MissingErrCode ParseErrCode )
const ( WhatPins = "pins" WhatStop = "stop" )
Variables ¶
var (
BadRequestErr = errors.New("Bad request")
)
Functions ¶
func ErrorsEqual ¶
ErrorsEqual() returns true if the errors are equivalent.
func MergeErrors ¶
MergeErrors() answers the first non-nil error in the list.
func NewBadRequestError ¶
func NewIllegalError ¶
func NewMissingError ¶
func NewParseError ¶
func Register ¶
func Register(fac NodeFactory) error
func RegisterVar ¶
func RegisterVar(name, descr string, optional_value interface{})
RegisterVar() registers a variable with the system, which becomes part of the help system. Multiple variables with the same name can be registered, since each package can have its own non-conflicting variables. You can supply an optional value and the var wil be including when replacing vars through the Environment, although only a single var with the same name can have a value.
func StringPinsEqual ¶
func StringPinsToJson ¶
func WalkStringItems ¶
func WalkStringItems(pins Pins, channel string, fn StringItemFunc)
WalkStringItems iterates over each string item on the channel
Types ¶
type BuildPinsCmd ¶
type BuildPinsCmd int
const ( PbsChan BuildPinsCmd // The following command must be a string. It will be used to // start a new pin with the given channel name. PbsDoc // Start a new doc. Can be ommitted after starting a channel. Only necessary )
type Doc ¶
Doc describes a single abstract document. It includes a user-defined header, an optional content type, and optional pages.
func (*Doc) AppendItem ¶
func (d *Doc) AppendItem(item interface{})
func (*Doc) StringItem ¶
func (*Doc) StringItems ¶
type Docs ¶
type Docs struct {
Docs []*Doc
}
Docs is a wrapper on a slice of Doc structs, used to add convenience management functions.
func (Docs) StringItem ¶
func (Docs) StringItems ¶
type Environment ¶
type Environment interface {
// FindFile() answers the full path to the phlyp by searching paths for name.
FindFile(name string) string
// FindReader() answers a reader for the given name.
FindReader(name string) io.Reader
// Utility for replacing strings with a collection of my vars and supplied pairs.
ReplaceVars(s string, pairs ...interface{}) string
}
Environment provides access to the system environment.
type InstantiateArgs ¶
type InstantiateArgs struct {
Env Environment
}
InstantiateArgs provides information during the instantiation phase.
type Items ¶
type Items interface {
// Get collections in various formats
AllItems() []interface{}
StringItems() []string
// Get at index in various formats
AllItem(index int) interface{}
StringItem(index int) string
}
Items provides common behaviour on an abstract collection.
type Msg ¶
type Msg struct {
What string
Payload interface{}
}
Msg is an abstract node message.
func MsgFromPins ¶
func MsgFromStop ¶
type Node ¶
type Node interface {
Describe() NodeDescr
// Process processes input, sending any results to output.
// stage provides minimal lifecycle information: whether this node is starting or not.
// input is the collection of inputs to process.
// output is used to send any output to the calling graph. It is also used to
// request StopNode() be called if processing should end.
// error is used to report any errors; not that it will immediately stop all
// graph processing.
Process(args ProcessArgs, stage NodeStage, input Pins, output NodeOutput) error
// Request to stop the node.
StopNode(args StoppedArgs) error
}
Node performs abstract document processing.
type NodeDescr ¶
type NodeDescr struct {
Id string
Name string
Purpose string
Cfgs []CfgDescr
StartupPins []PinDescr
InputPins []PinDescr
OutputPins []PinDescr
}
NodeDescr describes a node.
func (*NodeDescr) FindOutput ¶
func (*NodeDescr) MarkdownString ¶
type NodeFactory ¶
type NodeFactory interface {
Describe() NodeDescr
Instantiate(args InstantiateArgs, tree interface{}) (Node, error)
}
NodeFactory instantiates a node. All nodes should have their factories installed in the bootstrap.
type NodeOutput ¶
NodeOutput sends data from the node to its parent runner.
type NodeStage ¶
type NodeStage string
const ( NodeStarting NodeStage = "starting" NodeRunning = "running" )
type PinBuilder ¶
type PinBuilder struct {
// contains filtered or unexported fields
}
func (PinBuilder) Add ¶
func (b PinBuilder) Add(name string, item *Doc) PinBuilder
func (PinBuilder) Pins ¶
func (b PinBuilder) Pins() Pins
type Pins ¶
type Pins interface {
GetPin(name string) Docs
WalkPins(fn PinsWalkFunc)
}
Pins describes a collection of documents attached to named pins. It is meant for clients that are consuming pins.
func BuildPins ¶
BuildPins() builds a new Pins object according to the command stream. See the tokens for the rules. Any cmd that is not a token or made use of by the last token becomes a new item in the current doc. Example. The first command defaults to being the channel (so it must be a string).
BuildPins("input", "item1", "item2")
Example. You can use the channel command to create a new channel at any point.
BuildPins(PbsChannel, "input", "item1", "item2")
Example. You can use the doc command to create a new doc at any point.
BuildPins(PbsChannel, "input", "doc1_item1", PbsDoc, "doc2_item1")
func MustBuildPins ¶
func MustBuildPins(cmds ...interface{}) Pins
MustBuildPins() is identical to BuildPins but it will panic on an error. Intended only for testing
type PinsWalkFunc ¶
PinsWalkFunc iterates over each pin in a Pins collection.
type Pipeline ¶
type Pipeline interface {
Run(args StartArgs, input Pins) error
Start(args StartArgs, input Pins) error
Stop() error
Wait() error
}
func LoadPipeline ¶
type ProcessArgs ¶
type ProcessArgs struct {
// contains filtered or unexported fields
}
ProcessArgs provides arguments to the node during processing.
func (*ProcessArgs) ClaValue ¶
func (r *ProcessArgs) ClaValue(name string) string
ClaValue() answers the command line argument value for the given name.
func (*ProcessArgs) Env ¶
func (r *ProcessArgs) Env() Environment
func (*ProcessArgs) Filename ¶
func (r *ProcessArgs) Filename(rel string) string
Filename() answers an absolute filename for the supplied filename. Absolute filenames are returned as-is. Relative filenames are made relative to the cfg that generated the pipeline.
type SortNodeFactory ¶
type SortNodeFactory []NodeFactory
func (SortNodeFactory) Len ¶
func (s SortNodeFactory) Len() int
func (SortNodeFactory) Less ¶
func (s SortNodeFactory) Less(i, j int) bool
func (SortNodeFactory) Swap ¶
func (s SortNodeFactory) Swap(i, j int)
type StartArgs ¶
type StartArgs struct {
Cla map[string]string // Command line arguments
// contains filtered or unexported fields
}
StartArgs provides arguments when starting the pipeline.
type StopPayload ¶
type StopPayload struct {
Err error
}
type StoppedArgs ¶
type StoppedArgs struct {
}
StoppedArgs provides information as nodes are stopping.