Documentation
¶
Index ¶
- type Codec
- func (c *Codec) GRPCCodec() encoding.Codec
- func (c *Codec) MarshalProto(m proto.Message) ([]byte, error)
- func (c *Codec) MarshalProtoJSON(m proto.Message) ([]byte, error)
- func (c *Codec) NewAny(m proto.Message) (*anypb.Any, error)
- func (c *Codec) ProtoOptions() ProtoOptions
- func (c *Codec) UnmarshalProto(b []byte, m proto.Message) error
- func (c *Codec) UnmarshalProtoJSON(b []byte, m proto.Message) error
- type FileDescriptorSetRegistry
- func (f *FileDescriptorSetRegistry) Close() error
- func (f *FileDescriptorSetRegistry) FileCount() int
- func (f *FileDescriptorSetRegistry) HasSymbol(name string) bool
- func (f *FileDescriptorSetRegistry) ListFiles() []string
- func (f *FileDescriptorSetRegistry) ProtoFileByPath(path string) (*descriptorpb.FileDescriptorProto, error)
- func (f *FileDescriptorSetRegistry) ProtoFileContainingSymbol(name protoreflect.FullName) (*descriptorpb.FileDescriptorProto, error)
- func (f *FileDescriptorSetRegistry) SymbolCount() int
- type GRPCReflectionProtoFileRegistry
- func (g *GRPCReflectionProtoFileRegistry) Close() error
- func (g *GRPCReflectionProtoFileRegistry) ProtoFileByPath(path string) (_ *descriptorpb.FileDescriptorProto, err error)
- func (g *GRPCReflectionProtoFileRegistry) ProtoFileContainingSymbol(name protoreflect.FullName) (_ *descriptorpb.FileDescriptorProto, err error)
- type HybridProtoFileRegistry
- func (h *HybridProtoFileRegistry) Close() error
- func (h *HybridProtoFileRegistry) HasFileFallback() bool
- func (h *HybridProtoFileRegistry) IsReflectionAvailable() bool
- func (h *HybridProtoFileRegistry) ProtoFileByPath(path string) (*descriptorpb.FileDescriptorProto, error)
- func (h *HybridProtoFileRegistry) ProtoFileContainingSymbol(name protoreflect.FullName) (*descriptorpb.FileDescriptorProto, error)
- func (h *HybridProtoFileRegistry) ResetReflectionStatus()
- type HybridRegistryConfig
- type ProtoFileRegistry
- type ProtoOptions
- type Registry
- func (r *Registry) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error)
- func (r *Registry) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)
- func (r *Registry) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
- func (r *Registry) FindFileByPath(s string) (protoreflect.FileDescriptor, error)
- func (r *Registry) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error)
- func (r *Registry) FindMessageByURL(url string) (protoreflect.MessageType, error)
- func (r *Registry) Remote() ProtoFileRegistry
- func (r *Registry) Save() (*descriptorpb.FileDescriptorSet, error)
- type RelayerRemote
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 (*Codec) ProtoOptions ¶
func (c *Codec) ProtoOptions() ProtoOptions
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 ¶
func (f *FileDescriptorSetRegistry) ProtoFileByPath(path string) (*descriptorpb.FileDescriptorProto, error)
ProtoFileByPath returns the FileDescriptorProto for the given file path. Implements ProtoFileRegistry interface.
func (*FileDescriptorSetRegistry) ProtoFileContainingSymbol ¶
func (f *FileDescriptorSetRegistry) ProtoFileContainingSymbol(name protoreflect.FullName) (*descriptorpb.FileDescriptorProto, error)
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 (g *GRPCReflectionProtoFileRegistry) Close() error
func (*GRPCReflectionProtoFileRegistry) ProtoFileByPath ¶
func (g *GRPCReflectionProtoFileRegistry) ProtoFileByPath(path string) (_ *descriptorpb.FileDescriptorProto, err error)
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 ¶
func (h *HybridProtoFileRegistry) ProtoFileByPath(path string) (*descriptorpb.FileDescriptorProto, error)
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 ¶
func (r *Registry) Save() (*descriptorpb.FileDescriptorSet, error)
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)