dynamic

package
v0.0.0-...-48a44ca Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: Apache-2.0 Imports: 24 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 CheckOutput

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

CheckOutput is a generic container for the response of remote check calls with output. It is used to unpack the value using a combination of the static and dynamic decoders.

func (*CheckOutput) Bytes

func (out *CheckOutput) Bytes(n wire.Number, v []byte)

Bytes implements proto decoding interface

func (*CheckOutput) Fixed32

func (out *CheckOutput) Fixed32(wire.Number, uint32)

Fixed32 implements proto decoding interface

func (*CheckOutput) Fixed64

func (out *CheckOutput) Fixed64(wire.Number, uint64)

Fixed64 implements proto decoding interface

func (*CheckOutput) Varint

func (out *CheckOutput) Varint(wire.Number, uint64)

Varint implements proto decoding interface

type Codec

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

Codec in no-op on the way out and unmarshals using either normal means or a custom dynamic decoder on the way in

func (Codec) Marshal

func (c 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 (c Codec) String() string

String returns name of the codec.

func (Codec) Unmarshal

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

Unmarshal uses custom decoder or 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,
	output *attribute.MutableBag, outPrefix string) (*adapter.CheckResult, error)

HandleRemoteCheck implements adapter.RemoteCheckHandler api

func (*Handler) HandleRemoteGenAttrs

func (h *Handler) HandleRemoteGenAttrs(ctx context.Context, encodedInstance *adapter.EncodedInstance,
	out *attribute.MutableBag) error

HandleRemoteGenAttrs implements remote handler 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, variety v1beta1.TemplateVariety) (*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