function

package
v0.195.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Invoke

func Invoke[T any](f func(args *Arguments) (T, error), argsObj values.Object) (T, error)

Invoke calls a function and returns the result.

This is the same as InvokeContext but with a background context.

func InvokeContext

func InvokeContext[T any](f func(ctx context.Context, args *Arguments) (T, error), ctx context.Context, argsObj values.Object) (T, error)

InvokeContext calls a function and returns the result.

It passes the object as the arguments to the function and returns an error if any supplied arguments are not used.

Types

type Arguments

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

Arguments provides access to the arguments of a function call. This struct can only be created by using one of the Register functions to register a function or by directly calling Invoke.

func (*Arguments) Get

func (a *Arguments) Get(name string) (values.Value, bool)

func (*Arguments) GetArray

func (a *Arguments) GetArray(name string, t semantic.Nature) (values.Array, bool, error)

func (*Arguments) GetArrayAllowEmpty

func (a *Arguments) GetArrayAllowEmpty(name string, t semantic.Nature) (values.Array, bool, error)

func (*Arguments) GetBool

func (a *Arguments) GetBool(name string) (bool, bool, error)

func (*Arguments) GetDictionary

func (a *Arguments) GetDictionary(name string) (values.Dictionary, bool, error)

func (*Arguments) GetDuration

func (a *Arguments) GetDuration(name string) (flux.Duration, bool, error)

func (*Arguments) GetFloat

func (a *Arguments) GetFloat(name string) (float64, bool, error)

func (*Arguments) GetFunction

func (a *Arguments) GetFunction(name string) (values.Function, bool, error)

func (*Arguments) GetInt

func (a *Arguments) GetInt(name string) (int64, bool, error)

func (*Arguments) GetObject

func (a *Arguments) GetObject(name string) (values.Object, bool, error)

func (*Arguments) GetRequired

func (a *Arguments) GetRequired(name string) (values.Value, error)

func (*Arguments) GetRequiredArray

func (a *Arguments) GetRequiredArray(name string, t semantic.Nature) (values.Array, error)

func (*Arguments) GetRequiredArrayAllowEmpty

func (a *Arguments) GetRequiredArrayAllowEmpty(name string, t semantic.Nature) (values.Array, error)

GetRequiredArrayAllowEmpty ensures a required array (with element type) is present, but unlike GetRequiredArray, does not fail if the array is empty.

func (*Arguments) GetRequiredBool

func (a *Arguments) GetRequiredBool(name string) (bool, error)

func (*Arguments) GetRequiredDictionary

func (a *Arguments) GetRequiredDictionary(name string) (values.Dictionary, error)

func (*Arguments) GetRequiredDuration

func (a *Arguments) GetRequiredDuration(name string) (flux.Duration, error)

func (*Arguments) GetRequiredFloat

func (a *Arguments) GetRequiredFloat(name string) (float64, error)

func (*Arguments) GetRequiredFunction

func (a *Arguments) GetRequiredFunction(name string) (values.Function, error)

func (*Arguments) GetRequiredInt

func (a *Arguments) GetRequiredInt(name string) (int64, error)

func (*Arguments) GetRequiredObject

func (a *Arguments) GetRequiredObject(name string) (values.Object, error)

func (*Arguments) GetRequiredString

func (a *Arguments) GetRequiredString(name string) (string, error)

func (*Arguments) GetRequiredTime

func (a *Arguments) GetRequiredTime(name string) (flux.Time, error)

func (*Arguments) GetRequiredUInt

func (a *Arguments) GetRequiredUInt(name string) (uint64, error)

func (*Arguments) GetString

func (a *Arguments) GetString(name string) (string, bool, error)

func (*Arguments) GetTime

func (a *Arguments) GetTime(name string) (flux.Time, bool, error)

func (*Arguments) GetUInt

func (a *Arguments) GetUInt(name string) (uint64, bool, error)

type Builder

type Builder struct {
	PackagePath string
}

func ForPackage

func ForPackage(name string) Builder

func (Builder) Register

func (b Builder) Register(name string, fn Definition)

func (Builder) RegisterContext

func (b Builder) RegisterContext(name string, fn DefinitionContext)

func (Builder) RegisterSource

func (b Builder) RegisterSource(name string, kind plan.ProcedureKind, fn SourceDefinition)

func (Builder) RegisterTransformation

func (b Builder) RegisterTransformation(name string, kind plan.ProcedureKind, fn TransformationDefinition)

type Definition

type Definition func(args *Arguments) (values.Value, error)

type DefinitionContext

type DefinitionContext func(ctx context.Context, args *Arguments) (values.Value, error)

type Source

type Source interface {
	plan.ProcedureSpec
	CreateSource(id execute.DatasetID, a execute.Administration) (execute.Source, error)
}

type SourceDefinition

type SourceDefinition func(args *Arguments) (Source, error)

type Transformation

type Transformation interface {
	plan.ProcedureSpec
	CreateTransformation(id execute.DatasetID, a execute.Administration) (execute.Transformation, execute.Dataset, error)
}

type TransformationDefinition

type TransformationDefinition func(args *Arguments) (Transformation, error)

Jump to

Keyboard shortcuts

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