Documentation ¶
Index ¶
- Constants
- Variables
- func ModuleRegister(module, name string, fn *types.FuncValue)
- func Register(name string, fn *types.FuncValue)
- func StructRegister(moduleName string, args interface{}) error
- type WrappedFunc
- func (obj *WrappedFunc) ArgGen(index int) (string, error)
- func (obj *WrappedFunc) Info() *interfaces.Info
- func (obj *WrappedFunc) Init(init *interfaces.Init) error
- func (obj *WrappedFunc) Stream(ctx context.Context) error
- func (obj *WrappedFunc) String() string
- func (obj *WrappedFunc) Validate() error
Constants ¶
const ( // DirectInterface specifies whether we should use the direct function // API or not. If we don't use it, then these simple functions are // wrapped with the struct below. DirectInterface = false // XXX: fix any bugs and set to true! )
Variables ¶
var RegisteredFuncs = make(map[string]*types.FuncValue) // must initialize
RegisteredFuncs maps a function name to the corresponding static, pure func.
Functions ¶
func ModuleRegister ¶
ModuleRegister is exactly like Register, except that it registers within a named module. This is a helper function.
func Register ¶
Register registers a simple, static, pure function. It is easier to use than the raw function API, but also limits you to simple, static, pure functions.
func StructRegister ¶
StructRegister takes an CLI args struct with optional struct tags, and generates simple functions from the contained fields in the specified namespace. If no struct field named `func` is included, then a default function name which is the lower case representation of the field name will be used, otherwise the struct tag contents are used. If the struct tag contains the `-` character, then the field will be skipped. TODO: An alternative version of this might choose to return all of the values as a single giant struct.
Types ¶
type WrappedFunc ¶
type WrappedFunc struct { Name string Fn *types.FuncValue // contains filtered or unexported fields }
WrappedFunc is a scaffolding function struct which fulfills the boiler-plate for the function API, but that can run a very simple, static, pure function.
func (*WrappedFunc) ArgGen ¶
func (obj *WrappedFunc) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*WrappedFunc) Info ¶
func (obj *WrappedFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*WrappedFunc) Init ¶
func (obj *WrappedFunc) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*WrappedFunc) Stream ¶
func (obj *WrappedFunc) Stream(ctx context.Context) error
Stream returns the changing values that this func has over time.
func (*WrappedFunc) String ¶
func (obj *WrappedFunc) String() string
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*WrappedFunc) Validate ¶
func (obj *WrappedFunc) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.