Documentation ¶
Index ¶
- type BuilderSupportsTemplateFn
- type CreateInstanceBuilderFn
- type CreateOutputExpressionsFn
- type DispatchCheckFn
- type DispatchGenerateAttributesFn
- type DispatchQuotaFn
- type DispatchReportFn
- type ErrorPath
- type HandlerSupportsTemplateFn
- type InferTypeFn
- type Info
- type InstanceBuilderFn
- type OutputMapperFn
- type Repository
- type SetTypeFn
- type TypeEvalFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuilderSupportsTemplateFn ¶
type BuilderSupportsTemplateFn func(hndlrBuilder adapter.HandlerBuilder) bool
BuilderSupportsTemplateFn check if the handlerBuilder supports template.
type CreateInstanceBuilderFn ¶
type CreateInstanceBuilderFn func(instanceName string, instanceParam proto.Message, builder *compiled.ExpressionBuilder) (InstanceBuilderFn, error)
CreateInstanceBuilderFn returns a function that can build instances, based on the instanceParam:
// A CreateInstanceBuilderFn implementation: func(instanceName string, instanceParam interface{}, builder *compiled.ExpressionBuilder) (InstanceBuilderFn, error) { // Call an auto-generated function to create a builder struct. builder, err := newMyInstanceBuilder(instanceName, instanceParam, builder) if err != nil { return nil, err } // return an InstanceBuilderfn func(attrs attribute.Bag) (interface{}, error) { // myInstanceBuilder is an instance of a builder struct that this function closes over (see below). return myInstanceBuilder.build(bag) } } // Auto-generated method for creating a new builder struct func newMyInstanceBuilder(instanceName string, instanceParam interface{}, exprBuilder *compiled.ExpressionBuilder) (*myInstanceBuilder, error) { myInstanceParam := instanceParam.(*myInstanceParam) builder := &myInstanceBuilder{} builder.field1Builder, err = exprBuilder.Compile(myInstanceParam.field1Expression) if err != nil { return nil, err } }
type CreateOutputExpressionsFn ¶
type CreateOutputExpressionsFn func( instanceParam proto.Message, finder ast.AttributeDescriptorFinder, expb *compiled.ExpressionBuilder) (map[string]compiled.Expression, error)
CreateOutputExpressionsFn builds and returns a map of attribute names to the expression for calculating them.
// A CreateOutputExpressionsFn implementation: func(instanceParam interface{}, finder ast.AttributeDescriptorFinder, builder *compiled.ExpressionBuilder) (map[string]compiled.Expression, error) { // Convert the generic instanceParam to its specialized type. param := instanceParam.(*myInstanceParam) // Create a mapping of expressions back to the attribute names. expressions := make(map[string]compiled.Expression, len(param.AttributeBindings)) for attrName, outExpr := range param.AttributeBindings { // compile an expression and put it in expressions. } return expressions, nil }
type DispatchCheckFn ¶
type DispatchCheckFn func(ctx context.Context, handler adapter.Handler, instance interface{}) (adapter.CheckResult, error)
DispatchCheckFn dispatches the instance to the handler.
type DispatchGenerateAttributesFn ¶
type DispatchGenerateAttributesFn func(ctx context.Context, handler adapter.Handler, instance interface{}, attrs attribute.Bag, mapper OutputMapperFn) (*attribute.MutableBag, error)
DispatchGenerateAttributesFn dispatches the instance object to the attribute generating handler.
type DispatchQuotaFn ¶
type DispatchQuotaFn func(ctx context.Context, handler adapter.Handler, instance interface{}, args adapter.QuotaArgs) (adapter.QuotaResult, error)
DispatchQuotaFn dispatches the instance to the handler.
type DispatchReportFn ¶
type DispatchReportFn func(ctx context.Context, handler adapter.Handler, instances []interface{}) error
DispatchReportFn dispatches the instances to the handler.
type ErrorPath ¶
type ErrorPath struct {
// contains filtered or unexported fields
}
ErrorPath represents an error that occurred within a complicated object hierarchy. It allows keeping track of the path to the error location during unwinding, while keeping the amount of garbage generated to a minimum.
func NewErrorPath ¶
NewErrorPath gets called, during the unwinding of a generated call in a complicated object hierarchy, to start tracking of the location that the error has occurred.
func (ErrorPath) AsCompilationError ¶
AsCompilationError creates an actual error to be used in the compilation path.
func (ErrorPath) AsEvaluationError ¶
AsEvaluationError creates an actual error to be used in the evaluation path.
func (ErrorPath) WithPrefix ¶
WithPrefix adds the given prefix to the error path. Typically, this is called by an intermediate step during unwind to attach its own location information, before returning it up to the caller.
type HandlerSupportsTemplateFn ¶
HandlerSupportsTemplateFn check if the handler supports template.
type InferTypeFn ¶
InferTypeFn does Type inference from the Instance.params proto message.
type Info ¶
type Info struct { Name string Impl string Variety adptTmpl.TemplateVariety BldrInterfaceName string HndlrInterfaceName string CtrCfg proto.Message InferType InferTypeFn SetType SetTypeFn BuilderSupportsTemplate BuilderSupportsTemplateFn HandlerSupportsTemplate HandlerSupportsTemplateFn AttributeManifests []*pb.AttributeManifest DispatchReport DispatchReportFn DispatchCheck DispatchCheckFn DispatchQuota DispatchQuotaFn DispatchGenAttrs DispatchGenerateAttributesFn CreateInstanceBuilder CreateInstanceBuilderFn CreateOutputExpressions CreateOutputExpressionsFn }
Info contains all the information related a template like Default instance params, type inference method etc.
type InstanceBuilderFn ¶
InstanceBuilderFn builds and returns an instance, based on the attributes supplied. Typically, InstanceBuilderFn closes over an auto-generated "builder" struct which contains compiled expressions and sub-builders for the instance:
// An InstanceBuilderFn implementation: func(attrs attribute.Bag) (interface{}, error) { // myInstanceBuilder is an instance of a builder struct that this function closes over (see below). return myInstanceBuilder.build(bag) } // myInstanceBuilder is an auto-generated struct for building instances. They get instantiated // based on instance parameters (see CreateInstanceBuilderFn documentation): type myInstanceBuilder struct { // field1Builder builds the value of the field field1 of the instance. field1Builder compiled.Expression ... } func (b *myInstanceBuilder) build(attrs attribute.Bag) (*myInstance, error) { ... instance := &myInstance{} // Build the value of field1 if instance1.field1, err = b.field1Builder.EvaluateString(bag); err != nil { return nil, err } ... return instance, nil
type OutputMapperFn ¶
type OutputMapperFn func(attrs attribute.Bag) (*attribute.MutableBag, error)
OutputMapperFn maps the results of an APA output bag, with "$out"s, by processing it through AttributeBindings.
MapperFn: func(attrs attribute.Bag) (*attribute.MutableBag, error) {...} ProcessGenerateAttributes2Fn(..., attrs attribute.Bag) (*attribute.MutableBag, error) [ // use instance to call into the handler and get back a bag with "$out" values in it. outBag := ... // Call an OutputMapperFn to map "$out.<name>" parameters to actual attribute values resultBag := MapperFn(outBag) return resultBag, nil }
func NewOutputMapperFn ¶
func NewOutputMapperFn(expressions map[string]compiled.Expression) OutputMapperFn
NewOutputMapperFn creates and returns a function that creates new attributes, based on the supplied expression set.
type Repository ¶
type Repository interface { GetTemplateInfo(template string) (Info, bool) SupportsTemplate(hndlrBuilder adapter.HandlerBuilder, tmpl string) (bool, string) }
Repository defines all the helper functions to access the generated template specific types and fields.
func NewRepository ¶
func NewRepository(templateInfos map[string]Info) Repository
NewRepository returns an implementation of Repository