proto

package
v0.0.0-...-3cc3ff2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructFieldType

func ConstructFieldType(message *builder.MessageBuilder, key string, template specs.Template) (*builder.FieldType, error)

ConstructFieldType constructs a field constructor from the given property

func ConstructMessage

func ConstructMessage(message *builder.MessageBuilder, spec specs.Message) (err error)

ConstructMessage constructs a proto message of the given specs into the given message builders

func NewMessage

func NewMessage(resource string, message specs.Message) (*desc.MessageDescriptor, error)

NewMessage attempts to construct a new proto message descriptor for the given specs property

Types

type Constructor

type Constructor struct {
}

Constructor is capable of constructing new codec managers for the given resource and specs

func NewConstructor

func NewConstructor() *Constructor

NewConstructor constructs a new Proto constructor

func (*Constructor) Name

func (constructor *Constructor) Name() string

Name returns the proto codec constructor name

func (*Constructor) New

func (constructor *Constructor) New(resource string, specs *specs.ParameterMap) (codec.Manager, error)

New constructs a new proto codec manager

type ErrInvalidFieldType

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

ErrInvalidFieldType is thrown when the given field type is invalid

func (ErrInvalidFieldType) Error

func (e ErrInvalidFieldType) Error() string

func (ErrInvalidFieldType) Prettify

func (e ErrInvalidFieldType) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

type ErrNonRootMessage

type ErrNonRootMessage struct{}

ErrNonRootMessage occurs when message type is not root

func (ErrNonRootMessage) Error

func (e ErrNonRootMessage) Error() string

Error returns a description of the given error as a string

func (ErrNonRootMessage) Prettify

func (e ErrNonRootMessage) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

type ErrUndefinedSpecs

type ErrUndefinedSpecs struct{}

ErrUndefinedSpecs occurs when spacs are nil

func (ErrUndefinedSpecs) Error

func (e ErrUndefinedSpecs) Error() string

Error returns a description of the given error as a string

func (ErrUndefinedSpecs) Prettify

func (e ErrUndefinedSpecs) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

type Field

type Field specs.Template

Field represents a protobuf field

func (Field) Marshal

func (tmpl Field) Marshal(setter TrySetter, field *desc.FieldDescriptor, store references.Store, tracker references.Tracker) error

Marshal attempts to encode the given field as a protobuf field using the given setter

func (Field) Unmarshal

func (tmpl Field) Unmarshal(value interface{}, path string, store references.Store, tracker references.Tracker)

Unmarshal unmarshals the given protobuffer field into the given reference store.

type Manager

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

Manager represents a proto message encoder/decoder

func (*Manager) Marshal

func (manager *Manager) Marshal(store references.Store) (io.Reader, error)

Marshal marshals the given reference store into a proto message. This method is called during runtime to encode a new message with the values stored inside the given reference store.

func (*Manager) Name

func (manager *Manager) Name() string

Name returns the proto codec name

func (*Manager) Property

func (manager *Manager) Property() *specs.Property

Property returns the property used to marshal and unmarshal data

func (*Manager) Unmarshal

func (manager *Manager) Unmarshal(reader io.Reader, refs references.Store) error

Unmarshal unmarshals the given io reader into the given reference store. This method is called during runtime to decode a new message and store it inside the given reference store

type Message

type Message specs.Template

Message represents a protobuffer message

func (Message) Marshal

func (tmpl Message) Marshal(result *dynamic.Message, message *desc.MessageDescriptor, root string, store references.Store, tracker references.Tracker) error

Marshal attempts to encode the given template as a protobuf message using the given store.

func (Message) Unmarshal

func (tmpl Message) Unmarshal(protobuf *dynamic.Message, path string, store references.Store, tracker references.Tracker)

Unmarshal unmarshals the given protobuffer message into the given reference store.

type Method

type Method interface {
	GetName() string
	GetRequest() specs.Message
	GetResponse() specs.Message
}

Method represents a service mthod.

type Methods

type Methods map[string]Method

Methods represents a collection of methods.

type Repeated

type Repeated specs.Template

Repeated represents a repeated field with the given template

func (Repeated) Marshal

func (tmpl Repeated) Marshal(message *dynamic.Message, field *desc.FieldDescriptor, path string, store references.Store, tracker references.Tracker) error

Marshal attempts to marshal the given template as a protobuffer repeated value

func (Repeated) Unmarshal

func (tmpl Repeated) Unmarshal(protobuf *dynamic.Message, field *desc.FieldDescriptor, path string, store references.Store, tracker references.Tracker)

Unmarshal unmarshals the given repeated field into the given reference store.

type Service

type Service struct {
	Package string
	Name    string
	Methods Methods
}

Service represents a gRPC service.

func (*Service) FileDescriptor

func (service *Service) FileDescriptor() (*desc.FileDescriptor, error)

FileDescriptor generates protobuf file descriptor.

func (*Service) String

func (service *Service) String() string

String returns service full name.

type TrySetter

type TrySetter func(fd *desc.FieldDescriptor, val interface{}) error

TrySetter represents a protoreflect setter used to define various values

Jump to

Keyboard shortcuts

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