Documentation ¶
Index ¶
- Constants
- Variables
- func ContextWithMetadata[T ref.References[T]](ctx context.Context, md *Metadata[T]) context.Context
- func IsFullDepth(depth int) bool
- type Annotation
- type Evaluator
- func CoalesceEvaluators[T ref.References[T]](evs ...Evaluator[T]) Evaluator[T]
- func CoalesceEvaluatorsPreferringContext[T ref.References[T]](ctx context.Context, evs ...Evaluator[T]) Evaluator[T]
- func DefaultEvaluator[T ref.References[T]]() Evaluator[T]
- func NewEvaluator[T ref.References[T]](visitor Visitor[T]) Evaluator[T]
- type Expandable
- type Metadata
- func ContextWithEmptyMetadata[T ref.References[T]](ctx context.Context) (context.Context, *Metadata[T])
- func EmptyMetadata[T ref.References[T]]() *Metadata[T]
- func EvaluateInto[T ref.References[T]](ctx context.Context, ev Evaluator[T], from, to any) (*Metadata[T], error)
- func MetadataFromContext[T ref.References[T]](ctx context.Context) *Metadata[T]
- func NewMetadata[T ref.References[T]](refs T) *Metadata[T]
- func (m *Metadata[T]) AddStep(step *Result[T], annotations ...Annotation)
- func (m *Metadata[T]) InsertSteps(other *Metadata[T])
- func (m *Metadata[T]) MergeEvaluator(other *Metadata[T])
- func (m *Metadata[T]) MergeEvaluatorIfNotSet(other *Metadata[T])
- func (m *Metadata[T]) MergeReferences(other *Metadata[T])
- func (m *Metadata[T]) MergeSteps(other *Metadata[T])
- func (m *Metadata[T]) OK() bool
- func (m *Metadata[T]) Reduce()
- func (m *Metadata[T]) Resolved() bool
- func (m *Metadata[T]) SetAnnotation(annotation Annotation)
- func (m *Metadata[T]) SetEvaluator(ev Evaluator[T])
- type PathEvaluationError
- type Result
- func ContextualizedResult[T ref.References[T]](m *Metadata[T]) *Result[T]
- func EmptyResult[T ref.References[T]]() *Result[T]
- func EvaluateAll[T ref.References[T]](ctx context.Context, ev Evaluator[T], tree any) (*Result[T], error)
- func NewResult[T ref.References[T]](m *Metadata[T], v any) *Result[T]
- func StaticResult[T ref.References[T]](v any) *Result[T]
- type Step
- type UnsupportedValueError
- type Visitor
- type VisitorFuncs
- func (vfs *VisitorFuncs[T]) VisitExpandable(ctx context.Context, ex Expandable[T], depth int, next Evaluator[T]) (*Result[T], error)
- func (vfs *VisitorFuncs[T]) VisitMap(ctx context.Context, m map[string]any, depth int, next Evaluator[T]) (*Result[T], error)
- func (vfs *VisitorFuncs[T]) VisitSlice(ctx context.Context, s []any, depth int, next Evaluator[T]) (*Result[T], error)
- func (vfs *VisitorFuncs[T]) VisitString(ctx context.Context, s string, depth int, next Evaluator[T]) (*Result[T], error)
Constants ¶
View Source
const DepthFull = -1
Variables ¶
View Source
var ( ArrayAnnotation = Annotation{Name: "leg.relay.sh/array", Description: "array"} ExpansionAnnotation = Annotation{Name: "leg.relay.sh/expansion", Description: "expansion"} ObjectAnnotation = Annotation{Name: "leg.relay.sh/object", Description: "object"} )
Functions ¶
func ContextWithMetadata ¶
func IsFullDepth ¶
Types ¶
type Annotation ¶
func ArrayIndexAnnotation ¶
func ArrayIndexAnnotation(idx int) Annotation
func ObjectKeyAnnotation ¶
func ObjectKeyAnnotation(key string) Annotation
type Evaluator ¶
type Evaluator[T ref.References[T]] interface { Evaluate(ctx context.Context, tree any, depth int) (*Result[T], error) }
func CoalesceEvaluators ¶
func CoalesceEvaluators[T ref.References[T]](evs ...Evaluator[T]) Evaluator[T]
func DefaultEvaluator ¶
func DefaultEvaluator[T ref.References[T]]() Evaluator[T]
func NewEvaluator ¶
func NewEvaluator[T ref.References[T]](visitor Visitor[T]) Evaluator[T]
type Expandable ¶
type Expandable[T ref.References[T]] interface { Expand(ctx context.Context, depth int) (*Result[T], error) }
func MemoizedExpandable ¶
func MemoizedExpandable[T ref.References[T]](delegate Expandable[T]) Expandable[T]
func StaticExpandable ¶
func StaticExpandable[T ref.References[T]](r *Result[T]) Expandable[T]
type Metadata ¶
type Metadata[T ref.References[T]] struct { Annotation Annotation References T Steps []*Step[T] Evaluator Evaluator[T] }
func EmptyMetadata ¶
func EmptyMetadata[T ref.References[T]]() *Metadata[T]
func EvaluateInto ¶
func MetadataFromContext ¶
func MetadataFromContext[T ref.References[T]](ctx context.Context) *Metadata[T]
func NewMetadata ¶
func NewMetadata[T ref.References[T]](refs T) *Metadata[T]
func (*Metadata[T]) AddStep ¶
func (m *Metadata[T]) AddStep(step *Result[T], annotations ...Annotation)
func (*Metadata[T]) InsertSteps ¶
func (*Metadata[T]) MergeEvaluator ¶
func (*Metadata[T]) MergeEvaluatorIfNotSet ¶
func (*Metadata[T]) MergeReferences ¶
func (*Metadata[T]) MergeSteps ¶
func (*Metadata[T]) SetAnnotation ¶
func (m *Metadata[T]) SetAnnotation(annotation Annotation)
func (*Metadata[T]) SetEvaluator ¶
type PathEvaluationError ¶
func (*PathEvaluationError) Error ¶
func (e *PathEvaluationError) Error() string
func (*PathEvaluationError) Propagate ¶
func (e *PathEvaluationError) Propagate() bool
func (*PathEvaluationError) UnderlyingCause ¶
func (e *PathEvaluationError) UnderlyingCause() error
func (*PathEvaluationError) Unwrap ¶
func (e *PathEvaluationError) Unwrap() error
type Result ¶
type Result[T ref.References[T]] struct { *Metadata[T] Value any }
func ContextualizedResult ¶
func ContextualizedResult[T ref.References[T]](m *Metadata[T]) *Result[T]
func EmptyResult ¶
func EmptyResult[T ref.References[T]]() *Result[T]
func EvaluateAll ¶
func StaticResult ¶
func StaticResult[T ref.References[T]](v any) *Result[T]
type Step ¶
type Step[T ref.References[T]] struct { *Result[T] Annotations []Annotation }
type UnsupportedValueError ¶
func (*UnsupportedValueError) Error ¶
func (e *UnsupportedValueError) Error() string
func (*UnsupportedValueError) Propagate ¶
func (e *UnsupportedValueError) Propagate() bool
type Visitor ¶
type Visitor[T ref.References[T]] interface { VisitExpandable(ctx context.Context, ex Expandable[T], depth int, next Evaluator[T]) (*Result[T], error) VisitSlice(ctx context.Context, s []any, depth int, next Evaluator[T]) (*Result[T], error) VisitMap(ctx context.Context, m map[string]any, depth int, next Evaluator[T]) (*Result[T], error) VisitString(ctx context.Context, s string, depth int, next Evaluator[T]) (*Result[T], error) }
func DefaultVisitor ¶
func DefaultVisitor[T ref.References[T]]() Visitor[T]
type VisitorFuncs ¶
type VisitorFuncs[T ref.References[T]] struct { VisitExpandableFunc func(ctx context.Context, ex Expandable[T], depth int, next Evaluator[T]) (*Result[T], error) VisitSliceFunc func(ctx context.Context, s []any, depth int, next Evaluator[T]) (*Result[T], error) VisitMapFunc func(ctx context.Context, m map[string]any, depth int, next Evaluator[T]) (*Result[T], error) VisitStringFunc func(ctx context.Context, s string, depth int, next Evaluator[T]) (*Result[T], error) }
func (*VisitorFuncs[T]) VisitExpandable ¶
func (vfs *VisitorFuncs[T]) VisitExpandable(ctx context.Context, ex Expandable[T], depth int, next Evaluator[T]) (*Result[T], error)
func (*VisitorFuncs[T]) VisitSlice ¶
func (*VisitorFuncs[T]) VisitString ¶
Click to show internal directories.
Click to hide internal directories.