core

package
v0.0.0-...-48fa796 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2021 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TemplateName is the name of our template as required by the template
	// library.
	TemplateName = "template"
)

Variables

This section is empty.

Functions

func Len

func Len(input []types.Value) (types.Value, error)

Len returns the number of elements in a list or the number of key pairs in a map. It can operate on either of these types.

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 is the type of the input vars (2nd) arg if one is specified. Nil
	// is the special undetermined value that is used before type is known.
	Type *types.Type // type of vars
	// NoVars is set to true instead of specifying Type if we have a boring
	// template that takes no args.
	NoVars bool
	// 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL