Documentation ¶
Index ¶
- func ApplyTools(v interface{}, tc *ToolContext, tools ...*Tool) gomerr.Gomerr
- func Preprocess(v interface{}, tools ...*Tool) gomerr.Gomerr
- func RegisterToolFunction(name string, function ToolFunction) gomerr.Gomerr
- func RegisterToolFunctions(functions map[string]ToolFunction) gomerr.Gomerr
- func RegisterValueConstants(constants map[string]interface{})
- func ScopeAlias(alias, scope string)
- func ScopeAliases(aliasToScope map[string]string)
- func SetNowToolFunctionPrecision(precision time.Duration)
- func ValueFromStruct(sv reflect.Value, fv reflect.Value, source string) (interface{}, gomerr.Gomerr)
- type Applier
- type ApplierProvider
- type DirectiveProvider
- type NoApplier
- type StructApplier
- type StructTagDirectiveProvider
- type Tool
- type ToolContext
- func (tc *ToolContext) Descend(location string, createIntermediates bool) (*ToolContext, bool)
- func (tc *ToolContext) Get(key string) interface{}
- func (tc *ToolContext) Lookup(key string) (interface{}, bool)
- func (tc *ToolContext) LookupNested(key string) (*ToolContext, bool)
- func (tc *ToolContext) Put(key string, value interface{}) *ToolContext
- func (tc *ToolContext) PutScope(scope string) *ToolContext
- func (tc *ToolContext) Scope() string
- type ToolFunction
- type ValueApplier
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 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 ¶
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
type ApplierProvider ¶
type DirectiveProvider ¶
type DirectiveProvider interface {
Get(structType reflect.Type, structField reflect.StructField) string
}
type StructApplier ¶
type StructApplier struct {
Source string
}
func (StructApplier) Apply ¶
func (a StructApplier) Apply(sv reflect.Value, fv reflect.Value, _ *ToolContext) gomerr.Gomerr
type StructTagDirectiveProvider ¶
type StructTagDirectiveProvider struct {
TagKey string
}
func (StructTagDirectiveProvider) Get ¶
func (s StructTagDirectiveProvider) Get(_ reflect.Type, structField reflect.StructField) string
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
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 ¶
func (f ToolFunction) Apply(sv reflect.Value, fv reflect.Value, tc *ToolContext) gomerr.Gomerr
type ValueApplier ¶
type ValueApplier struct {
StaticValue string
}
func (ValueApplier) Apply ¶
func (a ValueApplier) Apply(_ reflect.Value, fv reflect.Value, _ *ToolContext) gomerr.Gomerr