Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/ottl]Godoc comments #30564

Merged
merged 8 commits into from
Feb 1, 2024
7 changes: 7 additions & 0 deletions pkg/ottl/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ func (e Expr[K]) Eval(ctx context.Context, tCtx K) (any, error) {
return e.exprFunc(ctx, tCtx)
}

// Getter resolves a value at runtime without performing any type checking on the value that is returned.
type Getter[K any] interface {
// Get retrieves a value of type 'Any' and returns an error if there are any issues during retrieval.
Get(ctx context.Context, tCtx K) (any, error)
}

// Setter allows setting an untyped value on a predefined field within some data at runtime.
type Setter[K any] interface {
// Set sets a value of type 'Any' and returns an error if there are any issues during the setting process.
Set(ctx context.Context, tCtx K, val any) error
}

// GetSetter is an interface that combines the Getter and Setter interfaces.
// It should be used to represent the ability to both get and set a value.```
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
type GetSetter[K any] interface {
Getter[K]
Setter[K]
Expand Down Expand Up @@ -284,6 +290,7 @@ func (g StandardBoolGetter[K]) Get(ctx context.Context, tCtx K) (bool, error) {

// FunctionGetter uses a function factory to return an instantiated function as an Expr.
type FunctionGetter[K any] interface {
// Get returns a function as an Expr[K] built with the provided Arguments
Get(args Arguments) (Expr[K], error)
}

Expand Down