dyncodec

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec struct {
	Registry *Registry
	// contains filtered or unexported fields
}

func NewCodec

func NewCodec(registry *Registry) *Codec

func (*Codec) GRPCCodec

func (c *Codec) GRPCCodec() encoding.Codec

func (*Codec) MarshalProto

func (c *Codec) MarshalProto(m proto.Message) ([]byte, error)

func (*Codec) MarshalProtoJSON

func (c *Codec) MarshalProtoJSON(m proto.Message) ([]byte, error)

func (*Codec) NewAny

func (c *Codec) NewAny(m proto.Message) (*anypb.Any, error)

func (*Codec) ProtoOptions

func (c *Codec) ProtoOptions() ProtoOptions

func (*Codec) UnmarshalProto

func (c *Codec) UnmarshalProto(b []byte, m proto.Message) error

func (*Codec) UnmarshalProtoJSON

func (c *Codec) UnmarshalProtoJSON(b []byte, m proto.Message) error

type FileDescriptorSetRegistry

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

FileDescriptorSetRegistry implements ProtoFileRegistry by loading descriptors from a pre-compiled FileDescriptorSet file (.pb format).

This is used when gRPC server reflection is disabled or unavailable. The FileDescriptorSet can be generated using protoc:

protoc --descriptor_set_out=output.pb --include_imports *.proto

Or using buf:

buf build -o output.pb

func NewFileDescriptorSetRegistry

func NewFileDescriptorSetRegistry(fds *descriptorpb.FileDescriptorSet) (*FileDescriptorSetRegistry, error)

NewFileDescriptorSetRegistry creates a new registry from a FileDescriptorSet. The FileDescriptorSet should contain all necessary proto files and their dependencies.

func NewFileDescriptorSetRegistryFromPath

func NewFileDescriptorSetRegistryFromPath(path string) (*FileDescriptorSetRegistry, error)

NewFileDescriptorSetRegistryFromPath loads a FileDescriptorSet from a file path. Supports binary .pb format.

func (*FileDescriptorSetRegistry) Close

func (f *FileDescriptorSetRegistry) Close() error

Close closes the registry and releases resources. Implements ProtoFileRegistry interface.

func (*FileDescriptorSetRegistry) FileCount

func (f *FileDescriptorSetRegistry) FileCount() int

FileCount returns the number of files in the registry

func (*FileDescriptorSetRegistry) HasSymbol

func (f *FileDescriptorSetRegistry) HasSymbol(name string) bool

HasSymbol checks if a symbol is indexed

func (*FileDescriptorSetRegistry) ListFiles

func (f *FileDescriptorSetRegistry) ListFiles() []string

ListFiles returns all indexed file paths

func (*FileDescriptorSetRegistry) ProtoFileByPath

ProtoFileByPath returns the FileDescriptorProto for the given file path. Implements ProtoFileRegistry interface.

func (*FileDescriptorSetRegistry) ProtoFileContainingSymbol

ProtoFileContainingSymbol returns the FileDescriptorProto containing the given symbol. The symbol can be a message, enum, service, or method full name. Implements ProtoFileRegistry interface.

func (*FileDescriptorSetRegistry) SymbolCount

func (f *FileDescriptorSetRegistry) SymbolCount() int

SymbolCount returns the number of indexed symbols

type GRPCReflectionProtoFileRegistry

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

GRPCReflectionProtoFileRegistry is a ProtoFileRegistry which uses grpc reflection to resolve files.

func NewGRPCReflectionProtoFileRegistryFromConn

func NewGRPCReflectionProtoFileRegistryFromConn(conn *grpc.ClientConn) *GRPCReflectionProtoFileRegistry

func (*GRPCReflectionProtoFileRegistry) Close

func (*GRPCReflectionProtoFileRegistry) ProtoFileByPath

func (*GRPCReflectionProtoFileRegistry) ProtoFileContainingSymbol

func (g *GRPCReflectionProtoFileRegistry) ProtoFileContainingSymbol(name protoreflect.FullName) (_ *descriptorpb.FileDescriptorProto, err error)

type HybridProtoFileRegistry

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

HybridProtoFileRegistry implements ProtoFileRegistry by trying multiple sources. It first attempts gRPC reflection, and falls back to a file-based registry if reflection fails.

This is useful for endpoints that may or may not have reflection enabled:

  • If reflection works, use it (auto-discovery of new methods)
  • If reflection fails, fall back to pre-compiled descriptors

The registry caches the reflection availability status to avoid repeated probe attempts.

func NewHybridProtoFileRegistry

func NewHybridProtoFileRegistry(config HybridRegistryConfig) (*HybridProtoFileRegistry, error)

NewHybridProtoFileRegistry creates a new hybrid registry. At least one of grpcConn or fileDescriptorSet/path must be provided.

func (*HybridProtoFileRegistry) Close

func (h *HybridProtoFileRegistry) Close() error

Close closes the registry and releases resources.

func (*HybridProtoFileRegistry) HasFileFallback

func (h *HybridProtoFileRegistry) HasFileFallback() bool

HasFileFallback returns true if a file-based fallback is configured

func (*HybridProtoFileRegistry) IsReflectionAvailable

func (h *HybridProtoFileRegistry) IsReflectionAvailable() bool

IsReflectionAvailable returns true if reflection is currently working

func (*HybridProtoFileRegistry) ProtoFileByPath

ProtoFileByPath returns the FileDescriptorProto for the given file path. Tries reflection first, falls back to file registry.

func (*HybridProtoFileRegistry) ProtoFileContainingSymbol

func (h *HybridProtoFileRegistry) ProtoFileContainingSymbol(name protoreflect.FullName) (*descriptorpb.FileDescriptorProto, error)

ProtoFileContainingSymbol returns the FileDescriptorProto containing the given symbol. Tries reflection first, falls back to file registry.

func (*HybridProtoFileRegistry) ResetReflectionStatus

func (h *HybridProtoFileRegistry) ResetReflectionStatus()

ResetReflectionStatus resets the reflection status to unknown, allowing the next query to probe reflection again. Useful after reconnection or endpoint changes.

type HybridRegistryConfig

type HybridRegistryConfig struct {
	// GRPCConn is the gRPC connection for reflection queries
	GRPCConn *grpc.ClientConn

	// ReflectionTimeout is the timeout for reflection queries
	// Default: 5 seconds
	ReflectionTimeout time.Duration

	// FileDescriptorSet is the fallback descriptor set
	// Can be nil if reflection is expected to always work
	FileDescriptorSet *descriptorpb.FileDescriptorSet

	// FileDescriptorPath is an alternative to FileDescriptorSet - path to .pb file
	FileDescriptorPath string
}

HybridRegistryConfig holds configuration for creating a HybridProtoFileRegistry

type ProtoFileRegistry

type ProtoFileRegistry interface {
	ProtoFileByPath(path string) (*descriptorpb.FileDescriptorProto, error)
	ProtoFileContainingSymbol(name protoreflect.FullName) (*descriptorpb.FileDescriptorProto, error)
	Close() error
}

type ProtoOptions

type ProtoOptions struct {
	Marshal       proto.MarshalOptions
	Unmarshal     proto.UnmarshalOptions
	JSONMarshal   protojson.MarshalOptions
	JSONUnmarshal protojson.UnmarshalOptions
}

type Registry

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

func NewRegistry

func NewRegistry(remote ProtoFileRegistry) *Registry

func (*Registry) FindDescriptorByName

func (r *Registry) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error)

func (*Registry) FindExtensionByName

func (r *Registry) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)

func (*Registry) FindExtensionByNumber

func (r *Registry) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)

func (*Registry) FindFileByPath

func (r *Registry) FindFileByPath(s string) (protoreflect.FileDescriptor, error)

func (*Registry) FindMessageByName

func (r *Registry) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error)

func (*Registry) FindMessageByURL

func (r *Registry) FindMessageByURL(url string) (protoreflect.MessageType, error)

func (*Registry) Remote

func (r *Registry) Remote() ProtoFileRegistry

func (*Registry) Save

type RelayerRemote

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

func NewRelayerRemote

func NewRelayerRemote(relay grpcproxy.ProxyCallBack) *RelayerRemote

func (RelayerRemote) Close

func (r RelayerRemote) Close() error

func (RelayerRemote) ProtoFileByPath

func (r RelayerRemote) ProtoFileByPath(path string) (*descriptorpb.FileDescriptorProto, error)

func (RelayerRemote) ProtoFileContainingSymbol

func (r RelayerRemote) ProtoFileContainingSymbol(name protoreflect.FullName) (*descriptorpb.FileDescriptorProto, error)

Jump to

Keyboard shortcuts

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