package structs
import "github.com/purpleidea/mgmt/lang/funcs/structs"
Index ¶
- Constants
- func FuncValueToConstFunc(fv *full.FuncValue) interfaces.Func
- func SimpleFnToConstFunc(name string, fv *types.FuncValue) interfaces.Func
- func SimpleFnToDirectFunc(name string, fv *types.FuncValue) interfaces.Func
- func SimpleFnToFuncValue(name string, fv *types.FuncValue) *full.FuncValue
- type CallFunc
- func (obj *CallFunc) Info() *interfaces.Info
- func (obj *CallFunc) Init(init *interfaces.Init) error
- func (obj *CallFunc) Stream(ctx context.Context) error
- func (obj *CallFunc) String() string
- func (obj *CallFunc) Validate() error
- type ChannelBasedSinkFunc
- func (obj *ChannelBasedSinkFunc) ArgGen(index int) (string, error)
- func (obj *ChannelBasedSinkFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)
- func (obj *ChannelBasedSinkFunc) Info() *interfaces.Info
- func (obj *ChannelBasedSinkFunc) Init(init *interfaces.Init) error
- func (obj *ChannelBasedSinkFunc) Stream(ctx context.Context) error
- func (obj *ChannelBasedSinkFunc) String() string
- func (obj *ChannelBasedSinkFunc) Validate() error
- type ChannelBasedSourceFunc
- func (obj *ChannelBasedSourceFunc) ArgGen(index int) (string, error)
- func (obj *ChannelBasedSourceFunc) Info() *interfaces.Info
- func (obj *ChannelBasedSourceFunc) Init(init *interfaces.Init) error
- func (obj *ChannelBasedSourceFunc) Stream(ctx context.Context) error
- func (obj *ChannelBasedSourceFunc) String() string
- func (obj *ChannelBasedSourceFunc) Validate() error
- type CompositeFunc
- func (obj *CompositeFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)
- func (obj *CompositeFunc) Info() *interfaces.Info
- func (obj *CompositeFunc) Init(init *interfaces.Init) error
- func (obj *CompositeFunc) Stream(ctx context.Context) error
- func (obj *CompositeFunc) String() string
- func (obj *CompositeFunc) StructCall(ctx context.Context, st types.Value) (types.Value, error)
- func (obj *CompositeFunc) Validate() error
- type ConstFunc
- func (obj *ConstFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)
- func (obj *ConstFunc) Info() *interfaces.Info
- func (obj *ConstFunc) Init(init *interfaces.Init) error
- func (obj *ConstFunc) Stream(ctx context.Context) error
- func (obj *ConstFunc) String() string
- func (obj *ConstFunc) Validate() error
- type ForFunc
- func (obj *ForFunc) Info() *interfaces.Info
- func (obj *ForFunc) Init(init *interfaces.Init) error
- func (obj *ForFunc) Stream(ctx context.Context) error
- func (obj *ForFunc) String() string
- func (obj *ForFunc) Validate() error
- type ForKVFunc
- func (obj *ForKVFunc) Info() *interfaces.Info
- func (obj *ForKVFunc) Init(init *interfaces.Init) error
- func (obj *ForKVFunc) Stream(ctx context.Context) error
- func (obj *ForKVFunc) String() string
- func (obj *ForKVFunc) Validate() error
- type IfFunc
- func (obj *IfFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)
- func (obj *IfFunc) Info() *interfaces.Info
- func (obj *IfFunc) Init(init *interfaces.Init) error
- func (obj *IfFunc) Stream(ctx context.Context) error
- func (obj *IfFunc) String() string
- func (obj *IfFunc) Validate() error
Constants ¶
const ( // CallFuncName is the unique name identifier for this function. CallFuncName = "call" // CallFuncArgNameFunction is the name for the edge which connects the // input function to CallFunc. CallFuncArgNameFunction = "fn" )
const ( // ForFuncName is the unique name identifier for this function. ForFuncName = "for" // ForFuncArgNameList is the name for the edge which connects the input // list to CallFunc. ForFuncArgNameList = "list" )
const ( // ForKVFuncName is the unique name identifier for this function. ForKVFuncName = "forkv" // ForKVFuncArgNameMap is the name for the edge which connects the input // map to CallFunc. ForKVFuncArgNameMap = "map" )
const ( // ChannelBasedSinkFuncArgName is the name for the edge which connects // the input value to ChannelBasedSinkFunc. ChannelBasedSinkFuncArgName = "channelBasedSinkFuncArg" )
const ( // CompositeFuncName is the unique name identifier for this function. CompositeFuncName = "composite" )
const ( // ConstFuncName is the unique name identifier for this function. ConstFuncName = "const" )
const ( // IfFuncName is the unique name identifier for this function. IfFuncName = "if" )
Functions ¶
func FuncValueToConstFunc ¶
func FuncValueToConstFunc(fv *full.FuncValue) interfaces.Func
FuncValueToConstFunc transforms a *full.FuncValue into an interfaces.Func which is implemented by &ConstFunc{}.
func SimpleFnToConstFunc ¶
func SimpleFnToConstFunc(name string, fv *types.FuncValue) interfaces.Func
SimpleFnToConstFunc transforms a name and *types.FuncValue into an interfaces.Func which is implemented by FuncValueToConstFunc and SimpleFnToFuncValue.
func SimpleFnToDirectFunc ¶
func SimpleFnToDirectFunc(name string, fv *types.FuncValue) interfaces.Func
SimpleFnToDirectFunc transforms a name and *types.FuncValue into an interfaces.Func which is implemented by &simple.WrappedFunc{}.
func SimpleFnToFuncValue ¶
SimpleFnToFuncValue transforms a name and *types.FuncValue into a *full.FuncValue.
Types ¶
type CallFunc ¶
type CallFunc struct { Type *types.Type // the type of the result of applying the function FuncType *types.Type // the type of the function EdgeName string // name of the edge used ArgVertices []interfaces.Func // contains filtered or unexported fields }
CallFunc receives a function from upstream, but not the arguments. Instead, the Funcs which emit those arguments must be specified at construction time. The arguments are connected to the received FuncValues in such a way that CallFunc emits the result of applying the function to the arguments.
func (*CallFunc) Info ¶
func (obj *CallFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*CallFunc) Init ¶
func (obj *CallFunc) Init(init *interfaces.Init) error
Init runs some startup code for this composite function.
func (*CallFunc) Stream ¶
Stream takes an input struct in the format as described in the Func and Graph methods of the Expr, and returns the actual expected value as a stream based on the changing inputs to that value.
func (*CallFunc) String ¶
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*CallFunc) Validate ¶
Validate makes sure we've built our struct properly.
type ChannelBasedSinkFunc ¶
type ChannelBasedSinkFunc struct { Name string EdgeName string Target interfaces.Func // for drawing dashed edges in the Graphviz visualization Chan chan types.Value Type *types.Type // contains filtered or unexported fields }
ChannelBasedSinkFunc is a Func which receives values from upstream nodes and emits them to a golang channel.
func (*ChannelBasedSinkFunc) ArgGen ¶
func (obj *ChannelBasedSinkFunc) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*ChannelBasedSinkFunc) Call ¶
Call this function with the input args and return the value if it is possible to do so at this time. XXX: Is is correct to implement this here for this particular function?
func (*ChannelBasedSinkFunc) Info ¶
func (obj *ChannelBasedSinkFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*ChannelBasedSinkFunc) Init ¶
func (obj *ChannelBasedSinkFunc) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*ChannelBasedSinkFunc) Stream ¶
func (obj *ChannelBasedSinkFunc) Stream(ctx context.Context) error
Stream returns the changing values that this func has over time.
func (*ChannelBasedSinkFunc) String ¶
func (obj *ChannelBasedSinkFunc) String() string
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*ChannelBasedSinkFunc) Validate ¶
func (obj *ChannelBasedSinkFunc) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.
type ChannelBasedSourceFunc ¶
type ChannelBasedSourceFunc struct { Name string Source interfaces.Func // for drawing dashed edges in the Graphviz visualization Chan chan types.Value Type *types.Type // contains filtered or unexported fields }
ChannelBasedSourceFunc is a Func which receives values from a golang channel and emits them to the downstream nodes.
func (*ChannelBasedSourceFunc) ArgGen ¶
func (obj *ChannelBasedSourceFunc) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*ChannelBasedSourceFunc) Info ¶
func (obj *ChannelBasedSourceFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*ChannelBasedSourceFunc) Init ¶
func (obj *ChannelBasedSourceFunc) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*ChannelBasedSourceFunc) Stream ¶
func (obj *ChannelBasedSourceFunc) Stream(ctx context.Context) error
Stream returns the changing values that this func has over time.
func (*ChannelBasedSourceFunc) String ¶
func (obj *ChannelBasedSourceFunc) String() string
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*ChannelBasedSourceFunc) Validate ¶
func (obj *ChannelBasedSourceFunc) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.
type CompositeFunc ¶
type CompositeFunc struct { Type *types.Type // this is the type of the composite value we hold Len int // length of list or map (if used) // contains filtered or unexported fields }
CompositeFunc is a function that passes through the value it receives. It is used to take a series of inputs to a list, map or struct, and return that value as a stream that depends on those inputs. It helps the list, map, and struct's that fulfill the Expr interface but expressing a Func method.
func (*CompositeFunc) Call ¶
Call this function with the input args and return the value if it is possible to do so at this time.
func (*CompositeFunc) Info ¶
func (obj *CompositeFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*CompositeFunc) Init ¶
func (obj *CompositeFunc) Init(init *interfaces.Init) error
Init runs some startup code for this composite function.
func (*CompositeFunc) Stream ¶
func (obj *CompositeFunc) Stream(ctx context.Context) error
Stream takes an input struct in the format as described in the Func and Graph methods of the Expr, and returns the actual expected value as a stream based on the changing inputs to that value.
func (*CompositeFunc) String ¶
func (obj *CompositeFunc) String() string
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*CompositeFunc) StructCall ¶
StructCall is a different Call API which is sometimes easier to implement.
func (*CompositeFunc) Validate ¶
func (obj *CompositeFunc) Validate() error
Validate makes sure we've built our struct properly.
type ConstFunc ¶
type ConstFunc struct { Value types.Value NameHint string // contains filtered or unexported fields }
ConstFunc is a function that returns the constant value passed to Value.
func (*ConstFunc) Call ¶
Call this function with the input args and return the value if it is possible to do so at this time.
func (*ConstFunc) Info ¶
func (obj *ConstFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*ConstFunc) Init ¶
func (obj *ConstFunc) Init(init *interfaces.Init) error
Init runs some startup code for this const.
func (*ConstFunc) Stream ¶
Stream returns the single value that this const has, and then closes.
func (*ConstFunc) String ¶
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*ConstFunc) Validate ¶
Validate makes sure we've built our struct properly.
type ForFunc ¶
type ForFunc struct { IndexType *types.Type ValueType *types.Type EdgeName string // name of the edge used AppendToIterBody func(innerTxn interfaces.Txn, index int, value interfaces.Func) error ClearIterBody func(length int) // contains filtered or unexported fields }
ForFunc receives a list from upstream. We iterate over the received list to build a subgraph that processes each element, and in doing so we get a larger function graph. This is rebuilt as necessary if the input list changes.
func (*ForFunc) Info ¶
func (obj *ForFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*ForFunc) Init ¶
func (obj *ForFunc) Init(init *interfaces.Init) error
Init runs some startup code for this composite function.
func (*ForFunc) Stream ¶
Stream takes an input struct in the format as described in the Func and Graph methods of the Expr, and returns the actual expected value as a stream based on the changing inputs to that value.
func (*ForFunc) String ¶
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*ForFunc) Validate ¶
Validate makes sure we've built our struct properly.
type ForKVFunc ¶
type ForKVFunc struct { KeyType *types.Type ValType *types.Type EdgeName string // name of the edge used SetOnIterBody func(innerTxn interfaces.Txn, ptr types.Value, key, val interfaces.Func) error ClearIterBody func(length int) // contains filtered or unexported fields }
ForKVFunc receives a map from upstream. We iterate over the received map to build a subgraph that processes each key and val, and in doing so we get a larger function graph. This is rebuilt as necessary if the input map changes.
func (*ForKVFunc) Info ¶
func (obj *ForKVFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*ForKVFunc) Init ¶
func (obj *ForKVFunc) Init(init *interfaces.Init) error
Init runs some startup code for this composite function.
func (*ForKVFunc) Stream ¶
Stream takes an input struct in the format as described in the Func and Graph methods of the Expr, and returns the actual expected value as a stream based on the changing inputs to that value.
func (*ForKVFunc) String ¶
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*ForKVFunc) Validate ¶
Validate makes sure we've built our struct properly.
type IfFunc ¶
type IfFunc struct { Type *types.Type // this is the type of the if expression output we hold // contains filtered or unexported fields }
IfFunc is a function that passes through the value of the correct branch based on the conditional value it gets.
func (*IfFunc) Call ¶
Call this function with the input args and return the value if it is possible to do so at this time. XXX: Is is correct to implement this here for this particular function?
func (*IfFunc) Info ¶
func (obj *IfFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*IfFunc) Init ¶
func (obj *IfFunc) Init(init *interfaces.Init) error
Init runs some startup code for this if expression function.
func (*IfFunc) Stream ¶
Stream takes an input struct in the format as described in the Func and Graph methods of the Expr, and returns the actual expected value as a stream based on the changing inputs to that value.
func (*IfFunc) String ¶
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*IfFunc) Validate ¶
Validate tells us if the input struct takes a valid form.
Source Files ¶
call.go channel_based_sink.go channel_based_source.go composite.go const.go for.go forkv.go if.go util.go
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 4 days ago –
Tools for package owners.