pb

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeProtobufToJSON

func DecodeProtobufToJSON(envelope, payload *dynamic.Message, data []byte, payloadFieldID int32) ([]byte, error)

DecodeProtobufToJSON is a wrapper for decoding/unmarshalling []byte of protobuf into a dynamic.Message and then marshalling that into JSON.

func FindMessageDescriptor

func FindMessageDescriptor(protobufDirs []string, protobufRootMessage string) (*desc.MessageDescriptor, error)

FindMessageDescriptor is a wrapper that will:

  1. Recursively find all .proto files in a directory
  2. Attempt to read and parse all files as proto FileDescriptors
  3. Attempt to find the specified "protobufRootMessage" type in the parsed FileDescriptors; if found, return the related MessageDescriptor

With the found MessageDescriptor, we are able to generate new dynamic messages via dynamic.NewMessage(..).

func FindMessageDescriptorInFDS added in v1.0.0

func FindMessageDescriptorInFDS(fds []*desc.FileDescriptor, rootMessage string) (*desc.MessageDescriptor, error)

Types

type MDType added in v1.0.4

type MDType string

MDType is used for type safety on message descriptor maps used in protobuf functions

var (
	MDEnvelope MDType = "envelope"
	MDPayload  MDType = "payload"
)

Jump to

Keyboard shortcuts

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