handler

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 18 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAndBuildArguments

func ValidateAndBuildArguments(resourceProvider yamlkit.ResourceProvider, functionContext *api.FunctionContext, invocation *api.FunctionInvocation, f *api.FunctionSignature) ([]api.FunctionArgument, error)

ValidateAndBuildArguments validates function arguments and builds an in-order argument list. It returns the validated arguments or an error if validation fails.

It rewrites invocation.Arguments in place, naming positional arguments and replacing each value with its evaluated and converted form, so the caller must own that slice's backing array.

Types

type FunctionHandler

type FunctionHandler struct {
	// contains filtered or unexported fields
}

func NewFunctionHandler

func NewFunctionHandler(provider ToolchainProvider) *FunctionHandler

NewFunctionHandler creates a new FunctionHandler with the given provider. The provider supplies the converter and resource provider, and the compute-mutations function is automatically registered.

func (*FunctionHandler) GetAttributes

func (fh *FunctionHandler) GetAttributes() []api.AttributeName

GetAttributes returns the list of registered attribute names from the path registry.

func (*FunctionHandler) GetConverter

func (fh *FunctionHandler) GetConverter() configkit.ConfigConverter

func (*FunctionHandler) GetHandlerImplementation

func (fh *FunctionHandler) GetHandlerImplementation(functionName string) FunctionImplementation

func (*FunctionHandler) GetPathRegistry

GetPathRegistry returns the path registry from the resource provider.

func (*FunctionHandler) GetResourceProvider

func (fh *FunctionHandler) GetResourceProvider() yamlkit.ResourceProvider

func (*FunctionHandler) Invoke

func (fh *FunctionHandler) Invoke(c echo.Context) error

func (*FunctionHandler) InvokeCore

func (fh *FunctionHandler) InvokeCore(ctx context.Context, functionInvocation *api.FunctionInvocationRequest) (*api.FunctionInvocationResponse, error)

func (*FunctionHandler) List

func (fh *FunctionHandler) List(c echo.Context) error

func (*FunctionHandler) ListCore

func (fh *FunctionHandler) ListCore() map[string]*FunctionRegistration

func (*FunctionHandler) ListPaths

func (fh *FunctionHandler) ListPaths(c echo.Context) error

func (*FunctionHandler) RegisterFunction

func (fh *FunctionHandler) RegisterFunction(functionName string, registration *FunctionRegistration) error

type FunctionImplementation

type FunctionImplementation func(args FunctionImplementationArguments) (gaby.Container, any, error)

type FunctionImplementationArguments

type FunctionImplementationArguments struct {
	FunctionContext *api.FunctionContext
	Options         *api.FunctionOptions
	ParsedData      gaby.Container
	ParsedOtherData map[api.OtherDataSource]gaby.Container
	Arguments       []api.FunctionArgument
}

FunctionImplementationArguments bundles all inputs to a function implementation.

type FunctionRegistration

type FunctionRegistration struct {
	api.FunctionSignature
	Function     FunctionImplementation `json:"-"` // implementation
	FunctionInit func() error           `json:"-"` // optional one-time initialization
}

type FunctionRegistry

type FunctionRegistry interface {
	RegisterFunction(functionName string, registration *FunctionRegistration) error
	GetHandlerImplementation(functionName string) FunctionImplementation
	GetPathRegistry() api.AttributeNameToResourceTypeToPathToVisitorInfoType
	GetAttributes() []api.AttributeName
	GetConverter() configkit.ConfigConverter
	GetResourceProvider() yamlkit.ResourceProvider
}

FunctionRegistry defines the interface for registering functions. This allows decoupling internal packages from the concrete FunctionHandler implementation.

type ToolchainProvider

type ToolchainProvider interface {
	configkit.ConfigConverter
	yamlkit.ResourceProvider
	GetToolchainType() workerapi.ToolchainType
}

ToolchainProvider combines the ConfigConverter and ResourceProvider interfaces. All built-in resource providers (k8skit, cubkit, etc.) implement both.

Jump to

Keyboard shortcuts

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