Documentation ¶
Index ¶
- func FunctionConnectionIDFromContext(ctx context.Context) (sdktypes.ConnectionID, error)
- func FunctionDataFromContext(ctx context.Context) []byte
- func FunctionValueFromContext(ctx context.Context) sdktypes.Value
- func UnpackArgs(args []sdktypes.Value, kwargs map[string]sdktypes.Value, dsts ...interface{}) error
- type FuncOpt
- type Module
- type Optfn
- type VarOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FunctionConnectionIDFromContext ¶ added in v0.5.0
func FunctionConnectionIDFromContext(ctx context.Context) (sdktypes.ConnectionID, error)
func FunctionDataFromContext ¶
func UnpackArgs ¶
UnpackArgs unpacks the positional and keyword arguments into the supplied parameter variables. pairs is an alternating list of names and pointers to variables.
If the parameter name ends with "?", it is optional. If the parameter name ends with "=", it must be supplied in kwargs. If the parameter name starts with "**", the destination will accept all kwargs as a dict. If the parameter name starts with "*", the destination will aceppt all args as a list.
Example:
func SomeFunc(ctx context.Context, args []sdktypes.Value, kwargs map[string]sdktypes.Value) (sdktypes.Value, error) { var ( x int y string args []int ) if err := UnpackArgs(args, kwargs, "x", &x, "y=", &y, "*args", &args); err != nil { return err } ... }
(this function is heavily inspired by https://pkg.go.dev/go.starlark.net/starlark#UnpackArgs, it essentially does the same thing, but on autokitteh level and not starlark)
TODO: varargs.
Types ¶
type FuncOpt ¶
type FuncOpt func(*funcOpts) error
func WithFlag ¶
func WithFlag(flag sdktypes.FunctionFlag) FuncOpt
func WithFlags ¶
func WithFlags(flags ...sdktypes.FunctionFlag) FuncOpt
func WithFuncDesc ¶
func WithFuncDoc ¶
type Module ¶
type Module interface { Describe() sdktypes.Module Configure(ctx context.Context, xid sdktypes.ExecutorID, cid sdktypes.ConnectionID) (map[string]sdktypes.Value, error) sdkexecutor.Caller }
type Optfn ¶
type Optfn func(*moduleOpts) error
func ExportFunction ¶
func ExportFunction(name string, fn sdkexecutor.Function, fopts ...FuncOpt) Optfn