istio: istio.io/istio/mixer/pkg/template Index | Files

package template

import "istio.io/istio/mixer/pkg/template"

Index

Package Files

errorpath.go template.go

type BuilderSupportsTemplateFn Uses

type BuilderSupportsTemplateFn func(hndlrBuilder adapter.HandlerBuilder) bool

BuilderSupportsTemplateFn check if the handlerBuilder supports template.

type CreateInstanceBuilderFn Uses

type CreateInstanceBuilderFn func(instanceName string, instanceParam proto.Message, builder lang.Compiler) (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 Uses

type CreateOutputExpressionsFn func(
    instanceParam proto.Message,
    finder attribute.AttributeDescriptorFinder,
    expb lang.Compiler) (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 Uses

type DispatchCheckFn func(ctx context.Context, handler adapter.Handler, instance interface{},
    out *attribute.MutableBag, outPrefix string) (cr adapter.CheckResult, err error)

DispatchCheckFn dispatches the instance to the handler. It may also produce output attributes in the output bag with the given prefix.

type DispatchGenerateAttributesFn Uses

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 Uses

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 Uses

type DispatchReportFn func(ctx context.Context, handler adapter.Handler, instances []interface{}) error

DispatchReportFn dispatches the instances to the handler.

type ErrorPath Uses

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 Uses

func NewErrorPath(path string, cause error) ErrorPath

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 Uses

func (e ErrorPath) AsCompilationError(instance string) error

AsCompilationError creates an actual error to be used in the compilation path.

func (ErrorPath) AsEvaluationError Uses

func (e ErrorPath) AsEvaluationError(instance string) error

AsEvaluationError creates an actual error to be used in the evaluation path.

func (ErrorPath) IsNil Uses

func (e ErrorPath) IsNil() bool

IsNil returns if the cause in ErrorPath is nil

func (ErrorPath) WithPrefix Uses

func (e ErrorPath) WithPrefix(prefix string) ErrorPath

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 Uses

type HandlerSupportsTemplateFn func(hndlr adapter.Handler) bool

HandlerSupportsTemplateFn check if the handler supports template.

type InferTypeFn Uses

type InferTypeFn func(proto.Message, TypeEvalFn) (proto.Message, error)

InferTypeFn does Type inference from the Instance.params proto message.

type Info Uses

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 Uses

type InstanceBuilderFn func(attrs attribute.Bag) (interface{}, error)

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 Uses

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 Uses

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 Uses

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 Uses

func NewRepository(templateInfos map[string]Info) Repository

NewRepository returns an implementation of Repository

type SetTypeFn Uses

type SetTypeFn func(types map[string]proto.Message, builder adapter.HandlerBuilder)

SetTypeFn dispatches the inferred types to handlers

type TypeEvalFn Uses

type TypeEvalFn func(string) (pb.ValueType, error)

TypeEvalFn evaluates an expression and returns the ValueType for the expression.

Package template imports 10 packages (graph) and is imported by 24 packages. Updated 2019-05-24. Refresh now. Tools for package owners.