structs

package
v0.0.0-...-8f66fda Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTools

func ApplyTools(v interface{}, tc *ToolContext, tools ...*Tool) gomerr.Gomerr

func Preprocess

func Preprocess(v interface{}, tools ...*Tool) gomerr.Gomerr

func RegisterToolFunction

func RegisterToolFunction(name string, function ToolFunction) gomerr.Gomerr

func RegisterToolFunctions

func RegisterToolFunctions(functions map[string]ToolFunction) gomerr.Gomerr

func RegisterValueConstants

func RegisterValueConstants(constants map[string]interface{})

func ScopeAlias

func ScopeAlias(alias, scope string)

ScopeAlias allows the caller to specify an alternative value to use when defining scoped configuration from the scope used during the application of a tool. Aliases need to be defined before PrepareTool() is called.

func ScopeAliases

func ScopeAliases(aliasToScope map[string]string)

func SetNowToolFunctionPrecision

func SetNowToolFunctionPrecision(precision time.Duration)

func ValueFromStruct

func ValueFromStruct(sv reflect.Value, fv reflect.Value, source string) (interface{}, gomerr.Gomerr)

Types

type Applier

type Applier interface {
	Apply(structValue reflect.Value, fieldValue reflect.Value, toolContext *ToolContext) gomerr.Gomerr
}

func Composite

func Composite(directive string, tool *Tool, st reflect.Type, sf reflect.StructField) (Applier, gomerr.Gomerr)

Composite checks for a composition directive (one of '?', '&' or '!') and if found creates a composed Applier from the directive on either side based on the specified semantic. If there isn't a composition directive, this returns nil for both Applier and gomerr.Gomerr. TODO:p2 this should perhaps be a default intermediary similar to how the scope applier can be

func ExpressionApplierProvider

func ExpressionApplierProvider(_ reflect.Type, sf reflect.StructField, directive string) (Applier, gomerr.Gomerr)

type ApplierProvider

type ApplierProvider interface {
	Applier(structType reflect.Type, structField reflect.StructField, directive string, scope string) (Applier, gomerr.Gomerr)
}

type DirectiveProvider

type DirectiveProvider interface {
	Get(structType reflect.Type, structField reflect.StructField) string
}

type NoApplier

type NoApplier struct{}

func (NoApplier) Apply

type StructApplier

type StructApplier struct {
	Source string
}

func (StructApplier) Apply

type StructTagDirectiveProvider

type StructTagDirectiveProvider struct {
	TagKey string
}

func (StructTagDirectiveProvider) Get

type Tool

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

Tool contains references to some behavior that can be applied to structs present in an application.

func NewTool

func NewTool(toolType string, ap ApplierProvider, dp DirectiveProvider) *Tool

func (*Tool) ApplierProvider

func (t *Tool) ApplierProvider() ApplierProvider

func (*Tool) Id

func (t *Tool) Id() string

func (*Tool) Type

func (t *Tool) Type() string

type ToolContext

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

func EnsureContext

func EnsureContext(tcs ...*ToolContext) *ToolContext

func ToolContextWithScope

func ToolContextWithScope(scope string) *ToolContext

func (*ToolContext) Descend

func (tc *ToolContext) Descend(location string, createIntermediates bool) (*ToolContext, bool)

func (*ToolContext) Get

func (tc *ToolContext) Get(key string) interface{}

func (*ToolContext) Lookup

func (tc *ToolContext) Lookup(key string) (interface{}, bool)

func (*ToolContext) LookupNested

func (tc *ToolContext) LookupNested(key string) (*ToolContext, bool)

func (*ToolContext) Put

func (tc *ToolContext) Put(key string, value interface{}) *ToolContext

func (*ToolContext) PutScope

func (tc *ToolContext) PutScope(scope string) *ToolContext

func (*ToolContext) Scope

func (tc *ToolContext) Scope() string

type ToolFunction

type ToolFunction func(structValue reflect.Value, fieldValue reflect.Value, toolContext *ToolContext) (output interface{}, ge gomerr.Gomerr)

func GetToolFunction

func GetToolFunction(name string) ToolFunction

func (ToolFunction) Apply

type ValueApplier

type ValueApplier struct {
	StaticValue string
}

func (ValueApplier) Apply

Jump to

Keyboard shortcuts

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