pb

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBlob added in v1.0.0

func CreateBlob(fds []*desc.FileDescriptor, rootType string) ([]byte, error)

CreateBlob marshals a root descriptor for storage

func DecodeProtobufToJSON

func DecodeProtobufToJSON(m *dynamic.Message, data []byte) ([]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)

func FindRootDescriptor added in v1.0.0

func FindRootDescriptor(rootType string, fds []*desc.FileDescriptor) *desc.FileDescriptor

func GetFDFromArchive added in v1.0.0

func GetFDFromArchive(archive []byte, rootDir string) ([]*desc.FileDescriptor, map[string]string, error)

GetFDFromArchive is the main entry point for processing of a zip archive of protobuf definitions

func GetMDFromDescriptorBlob added in v1.0.0

func GetMDFromDescriptorBlob(blob []byte, rootType string) (*desc.MessageDescriptor, error)

GetMDFromDescriptorBlob takes a stored schemas's file descriptorset blob and returns the necessary message descriptor for the given rootType

func GetMDFromDescriptors added in v1.0.0

func GetMDFromDescriptors(fds []*desc.FileDescriptor, rootType string) (*desc.MessageDescriptor, error)

GetMDFromDescriptors takes a stored schema's file descriptorset blob and returns the necessary message descriptor for the given rootType

func GetMessageDescriptor added in v1.0.0

func GetMessageDescriptor(latestVersion *protos.SchemaVersion, pbSettings *encoding.ProtobufSettings) (*desc.MessageDescriptor, error)

GetMessageDescriptor is a protobuf-specific function that returns a message descriptor using either the provided stored schema ID or using the provided protobuf zip file and root type.

Either cachedSchemaOptions or pbSettings can be nil (but not both).

NOTE: The signature for this function is unfortunately a bit funky - this is because we would _prefer_ to get a schemaID & a persistent config, but that causes import cycle errors.

So, the expectation for the usage of this func is to call it as follows:

GetMessageDescriptor(persistentConfig.GetSchema(schemaID), req.Opts.EncodeSettings.ProtobufSettings)

Types

This section is empty.

Jump to

Keyboard shortcuts

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