package wrapped

import "github.com/purpleidea/mgmt/lang/funcs/wrapped"

Index

Types

type Func

type Func struct {

	// Name is a unique string name for the function.
	Name string

	// Type is the type of the function. It can include unification
	// variables when this struct is wrapped in one that can build this out.
	Type *types.Type

	// Fn is the concrete version of our chosen function.
	Fn *types.FuncValue
	// contains filtered or unexported fields
}

Func is a wrapped scaffolding function struct which fulfills the boiler-plate for the function API, but that can run a very simple, static, pure, function. It can be wrapped by other structs that support polymorphism in various ways.

func (*Func) ArgGen

func (obj *Func) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*Func) Call

func (obj *Func) Call(ctx context.Context, args []types.Value) (types.Value, error)

Call this function with the input args and return the value if it is possible to do so at this time.

func (*Func) Info

func (obj *Func) Info() *interfaces.Info

Info returns some static info about itself.

func (*Func) Init

func (obj *Func) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*Func) Stream

func (obj *Func) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*Func) String

func (obj *Func) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*Func) Validate

func (obj *Func) Validate() error

Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.

Source Files

wrapped.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
4 days ago

Tools for package owners.