dynamic

package
v0.0.0-...-d8a8f93 Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeBool

func EncodeBool(v interface{}, ba []byte) ([]byte, error)

EncodeBool encodes input as boolean.

func EncodeDouble

func EncodeDouble(v interface{}, ba []byte) ([]byte, error)

EncodeDouble encode Double.

func EncodeEnum

func EncodeEnum(v interface{}, ba []byte, enumValues []*descriptor.EnumValueDescriptorProto) ([]byte, error)

EncodeEnum encodes enum from string or int inputs

func EncodeFixed32

func EncodeFixed32(v interface{}, ba []byte) ([]byte, error)

EncodeFixed32 encodes FIXED32, SFIXED32

func EncodeFixed64

func EncodeFixed64(v interface{}, ba []byte) ([]byte, error)

EncodeFixed64 encodes FIXED64, SFIXED64

func EncodeFloat

func EncodeFloat(v interface{}, ba []byte) ([]byte, error)

EncodeFloat encode Float.

func EncodeInt

func EncodeInt(v interface{}, ba []byte) ([]byte, error)

EncodeInt encodes (U)INT(32/64)

func EncodeSInt32

func EncodeSInt32(v interface{}, ba []byte) ([]byte, error)

EncodeSInt32 encodes sint32 as zigzag

func EncodeSInt64

func EncodeSInt64(v interface{}, ba []byte) ([]byte, error)

EncodeSInt64 encodes sint64 as zigzag

func EncodeString

func EncodeString(v interface{}, ba []byte) ([]byte, error)

EncodeString encodes string

func EncodeVarint

func EncodeVarint(buf []byte, x uint64) ([]byte, int)

EncodeVarint -- encodeVarint no allocations

func EncodeVarintZeroExtend

func EncodeVarintZeroExtend(ba []byte, x uint64, minBytes int) []byte

EncodeVarintZeroExtend encodes x as Varint in ba. Ensures that encoding is at least minBytes long.

Types

type Builder

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

Builder builds encoder based on data

func NewEncoderBuilder

func NewEncoderBuilder(resolver yaml.Resolver, compiler Compiler, skipUnknown bool) *Builder

NewEncoderBuilder creates an EncoderBuilder.

func (Builder) Build

func (c Builder) Build(msgName string, data map[string]interface{}) (Encoder, error)

Build builds an Encoder

func (Builder) BuildWithLength

func (c Builder) BuildWithLength(msgName string, data map[string]interface{}) (Encoder, error)

BuildWithLength builds an Encoder that also encodes length of the top level message.

type Codec

type Codec struct{}

Codec in no-op on the way out and unmarshals using normal means on the way in.

func (Codec) Marshal

func (Codec) Marshal(v interface{}) ([]byte, error)

Marshal does a noo-op marshal if input in bytes, otherwise it is an error.

func (Codec) String

func (Codec) String() string

String returns name of the codec.

func (Codec) Unmarshal

func (Codec) Unmarshal(data []byte, v interface{}) error

Unmarshal delegates to standard proto Unmarshal

type Compiler

type Compiler interface {
	// Compile creates a compiled expression from a string expression
	Compile(expr string) (compiled.Expression, v1beta1.ValueType, error)
}

Compiler creates a compiled expression from a string expression

type Encoder

type Encoder interface {
	Encode(bag attribute.Bag, ba []byte) ([]byte, error)
}

Encoder transforms yaml/json that represents protobuf data into []byte String values (rvalues) are treated as expressions that are evaluated using attribute bag at runtime. Quoted String values are treated as literals.

func BuildPrimitiveEncoder

func BuildPrimitiveEncoder(v interface{}, fld *descriptor.FieldDescriptorProto) (Encoder, error)

BuildPrimitiveEncoder encodes the given data and returns a static encoder.

func BuildPrimitiveEvalEncoder

func BuildPrimitiveEvalEncoder(expr compiled.Expression, vt v1beta1.ValueType, fld *descriptor.FieldDescriptorProto) (Encoder, error)

BuildPrimitiveEvalEncoder returns an eval encoder given an expression and a target fieldEncoder

type Handler

type Handler struct {
	// Name is used for debug
	Name string
	// contains filtered or unexported fields
}

Handler is the dynamic handler implementation

func BuildHandler

func BuildHandler(name string, connConfig *policypb.Connection, sessionBased bool, adapterConfig proto.Marshaler,
	templateConfig []*TemplateConfig) (hh *Handler, err error)

BuildHandler creates a dynamic handler object exposing specific handler interfaces.

func (*Handler) Close

func (h *Handler) Close() error

Close implements io.Closer api

func (*Handler) HandleRemoteCheck

func (h *Handler) HandleRemoteCheck(ctx context.Context, encodedInstance *adapter.EncodedInstance) (*adapter.CheckResult, error)

HandleRemoteCheck implements adapter.RemoteCheckHandler api

func (*Handler) HandleRemoteQuota

func (h *Handler) HandleRemoteQuota(ctx context.Context, encodedInstance *adapter.EncodedInstance,
	args *adapter.QuotaArgs) (*adapter.QuotaResult, error)

HandleRemoteQuota implements adapter.RemoteQuotaHandler api

func (*Handler) HandleRemoteReport

func (h *Handler) HandleRemoteReport(ctx context.Context, encodedInstances []*adapter.EncodedInstance) error

HandleRemoteReport implements adapter.RemoteReportHandler api

type NamedEncoderBuilderFunc

type NamedEncoderBuilderFunc func(m *descriptor.DescriptorProto, fd *descriptor.FieldDescriptorProto, v interface{}, compiler Compiler) (Encoder, error)

NamedEncoderBuilderFunc funcs have a special way to process input for encoding specific types for example istio...Value field accepts user input in a specific way

type Svc

type Svc struct {
	Name       string
	Pkg        string
	MethodName string
	InputType  string
	OutputType string

	TemplateName string
	// contains filtered or unexported fields
}

Svc encapsulates abstract service

func RemoteAdapterSvc

func RemoteAdapterSvc(namePrefix string, res protoyaml.Resolver, sessionBased bool,
	adapterConfig proto.Marshaler, templateName string) (*Svc, error)

RemoteAdapterSvc returns RemoteAdapter service

func (Svc) GrpcPath

func (s Svc) GrpcPath() string

GrpcPath returns grpc POST url for this service.

type TemplateConfig

type TemplateConfig struct {
	Name         string
	TemplateName string
	FileDescSet  *descriptor.FileDescriptorSet
	Variety      v1beta1.TemplateVariety
}

TemplateConfig is template configuration

Jump to

Keyboard shortcuts

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