protobuf

package
v0.0.0-...-4a75788 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect(importPaths, servicePaths []string) ([]*desc.FileDescriptor, error)

Collect takes import paths and service paths, walks all of the service paths and then parses the protos and returns all related file descriptors

func Construct

func Construct(messageDescriptor *desc.MessageDescriptor, request []byte) (*dynamic.Message, error)

Construct takes a message descriptor and a message, as JSON and returns it as a message, or an error if there's issues marshalling

func NormalizeMessageName

func NormalizeMessageName(name string) string

Trims starting "." because message names from the input types come in with a "." prepended

Types

type Collector

type Collector struct {
	// Maps message type name to descriptor
	MessageCache map[string]*desc.MessageDescriptor
	// Maps services name to descriptor
	ServiceCache map[string]*desc.ServiceDescriptor
}

Collector holds onto a cache of descriptors

func NewCollector

func NewCollector(fileDescriptors []*desc.FileDescriptor) *Collector

NewCollector returns an instance of a Collector struct

func (*Collector) AddDescriptors

func (c *Collector) AddDescriptors(fileDescriptors []*desc.FileDescriptor)

AddDescriptors takes a slice of file descriptors, walks them, and then saves all message and service descriptors to a cache with the key as the FQDN

func (*Collector) GetMessage

func (c *Collector) GetMessage(name string) (*desc.MessageDescriptor, error)

GetMessage takes a message descriptor's FQDN and returns the descriptor or an error if not found

func (*Collector) GetService

func (c *Collector) GetService(name string) (*desc.ServiceDescriptor, error)

GetService takes a service descriptor's FQDN and returns the descriptor or an error if not found

func (*Collector) ListServices

func (c *Collector) ListServices()

ListServices lists back the services in a formatted method

Jump to

Keyboard shortcuts

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