Documentation ¶
Index ¶
- Constants
- func Len(input []types.Value) (types.Value, error)
- type Random1Func
- type TemplateFunc
- func (obj *TemplateFunc) ArgGen(index int) (string, error)
- func (obj *TemplateFunc) Build(typ *types.Type) error
- func (obj *TemplateFunc) Close() error
- func (obj *TemplateFunc) Info() *interfaces.Info
- func (obj *TemplateFunc) Init(init *interfaces.Init) error
- func (obj *TemplateFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)
- func (obj *TemplateFunc) Stream() error
- func (obj *TemplateFunc) Validate() error
Constants ¶
const ( // TemplateName is the name of our template as required by the template // library. TemplateName = "template" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Random1Func ¶
type Random1Func struct {
// contains filtered or unexported fields
}
Random1Func returns one random string of a certain length. XXX: return a stream instead, and combine this with a first(?) function which takes the first value and then puts backpressure on the stream. This should notify parent functions somehow that their values are no longer required so that they can shutdown if possible. Maybe it should be returning a stream of floats [0,1] as well, which someone can later map to the alphabet that they want. Should random() take an interval to know how often to spit out values? It could also just do it once per second, and we could filter for less. If we want something high precision, we could add that in the future... We could name that "random" and this one can be "random1" until we deprecate it.
func (*Random1Func) ArgGen ¶
func (obj *Random1Func) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*Random1Func) Close ¶
func (obj *Random1Func) Close() error
Close runs some shutdown code for this function and turns off the stream.
func (*Random1Func) Info ¶
func (obj *Random1Func) Info() *interfaces.Info
Info returns some static info about itself.
func (*Random1Func) Init ¶
func (obj *Random1Func) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*Random1Func) Stream ¶
func (obj *Random1Func) Stream() error
Stream returns the single value that was generated and then closes.
func (*Random1Func) Validate ¶
func (obj *Random1Func) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.
type TemplateFunc ¶
type TemplateFunc struct { Type *types.Type // type of vars // contains filtered or unexported fields }
TemplateFunc is a static polymorphic function that compiles a template and returns the output as a string. It bases its output on the values passed in to it. It examines the type of the second argument (the input data vars) at compile time and then determines the static functions signature by including that in the overall signature. TODO: We *might* need to add events for internal function changes over time, but only if they are not pure. We currently only use simple, pure functions.
func (*TemplateFunc) ArgGen ¶
func (obj *TemplateFunc) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*TemplateFunc) Build ¶
func (obj *TemplateFunc) Build(typ *types.Type) error
Build takes the now known function signature and stores it so that this function can appear to be static. It extracts the type of the vars argument, which is the dynamic part which can change. That type is used to build our function statically.
func (*TemplateFunc) Close ¶
func (obj *TemplateFunc) Close() error
Close runs some shutdown code for this function and turns off the stream.
func (*TemplateFunc) Info ¶
func (obj *TemplateFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*TemplateFunc) Init ¶
func (obj *TemplateFunc) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*TemplateFunc) Polymorphisms ¶
func (obj *TemplateFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)
Polymorphisms returns the possible type signatures for this template. In this case, since the second argument can be an infinite number of values, it instead returns either the final precise type (if it can be gleamed from the input partials) or if it cannot, it returns a single entry with the complete type but with the variable second argument specified as a `variant` type. If it encounters any partial type specifications which are not possible, then it errors out. This could happen if you specified a non string template arg. XXX: is there a better API than returning a buried `variant` type?
func (*TemplateFunc) Stream ¶
func (obj *TemplateFunc) Stream() error
Stream returns the changing values that this func has over time.
func (*TemplateFunc) Validate ¶
func (obj *TemplateFunc) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.