protobuf

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(b []byte, pd *dymessage.MessageDef, e *dymessage.Entity) (*dymessage.Entity, error)

Decode transforms the protocol buffers representation of the message to specified dynamic entity against the provided message definition. The returned entity is the one that has been provided as an input parameter e, but now populated with the data.

If the entity type doesn't correspond the data type of the message definition, the method will panic.

func DecodeNew

func DecodeNew(b []byte, pd *dymessage.MessageDef) (*dymessage.Entity, error)

DecodeNew transforms the protocol buffers representation of the message to a dynamic entity against the provided message definition.

func Encode

func Encode(e *dymessage.Entity, pd *dymessage.MessageDef) ([]byte, error)

Encode encodes the data from the dynamic entity into a protocol buffers format. If the entity type doesn't correspond the data type of the message definition, the method will panic.

func ExportToProto

func ExportToProto(r *Registry, loc ExportLocator) error

ExportToProto transforms the messages in a whole registry into the .proto version 3 files, so the clients of the application could generate their own sources on their favorite languages with protoc and then communicate with the application.

func WithVarint

func WithVarint() func(*dymessage.MessageFieldDef)

WithVarint produces a function to extend the message field definition, indicating that the value must be represented by a ZigZag encoding.

Use this function with the ExtendField method of MessageDefBuilder.

func WithZigZag

func WithZigZag() func(*dymessage.MessageFieldDef)

WithZigZag produces a function to extend the message field definition, indicating that the value must be represented by a ZigZag encoding.

Use this function with the ExtendField method of MessageDefBuilder.

Types

type ExportLocator

type ExportLocator interface {
	// CreateWriter should create a writer for definitions of the message, found
	// at specified namespace in the repository. After the writer has been
	// returned, the caller is supposed to close it, if necessary.
	CreateWriter(ns string) (io.Writer, error)
	// GetImport gets a relative path to the file that implements messages
	// declared in provided namespace.
	GetImport(ns string) string
}

Provides methods to locate where the exported protocol definition files will be located. See the ExportToProto function for details.

type FileSystemLocator

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

Implements a location that puts the created proto definitions into specified directory.

func NewFileSystemLocator

func NewFileSystemLocator(root string, flatten bool) *FileSystemLocator

NewFileSystemLocator creates a file locator that puts the message definitions into the file system. The flatten parameter indicates whether files from all namespaces must be put into a single directory. Otherwise they are located in a hierarchy according to entries of namespace.

func (*FileSystemLocator) CreateWriter

func (f *FileSystemLocator) CreateWriter(ns string) (io.Writer, error)

func (*FileSystemLocator) GetImport

func (f *FileSystemLocator) GetImport(ns string) string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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