Documentation
¶
Overview ¶
Package resolve bridges the protoregistry namespace snapshots with protobuf-go's protoregistry types, enabling runtime type resolution for external consumers.
A Resolver wraps a namespace and exposes its current compiled descriptors through the standard protobuf-go interfaces (protodesc.Resolver, protoregistry.MessageTypeResolver, etc.). When a snapshot is hot-swapped, the resolver automatically sees the new types.
Index ¶
- type Resolver
- func (r *Resolver) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error)
- func (r *Resolver) FindDescriptorByNameWithOrigin(name protoreflect.FullName) (protoreflect.Descriptor, string, error)
- func (r *Resolver) FindExtensionByName(name protoreflect.FullName) (protoreflect.ExtensionType, error)
- func (r *Resolver) FindExtensionByNameWithOrigin(name protoreflect.FullName) (protoreflect.ExtensionType, string, error)
- func (r *Resolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
- func (r *Resolver) FindExtensionByNumberWithOrigin(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, string, error)
- func (r *Resolver) FindFileByPath(path string) (protoreflect.FileDescriptor, error)
- func (r *Resolver) FindFileByPathWithOrigin(path string) (protoreflect.FileDescriptor, string, error)
- func (r *Resolver) FindMessageByName(name protoreflect.FullName) (protoreflect.MessageType, error)
- func (r *Resolver) FindMessageByNameWithOrigin(name protoreflect.FullName) (protoreflect.MessageType, string, error)
- func (r *Resolver) FindMessageByURL(url string) (protoreflect.MessageType, error)
- func (r *Resolver) FindMessageByURLWithOrigin(url string) (protoreflect.MessageType, string, error)
- func (r *Resolver) NewMessage(name protoreflect.FullName) (*dynamicpb.Message, error)
- type SchemaResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver provides type resolution for a specific namespace by delegating to the current snapshots. It implements the standard protobuf-go resolver interfaces so it can be used with dynamicpb, encoding/protojson, etc.
The resolver is live: it always reads the current snapshot, so hot-swaps are immediately reflected without recreating the resolver.
Resolver also walks the namespace hierarchy chain on lookup miss (decision D7 in docs/design/namespace-hierarchy.md): when a symbol is not found in the publishing namespace's current snapshots, the search continues through each ancestor namespace in chain order. The nearest tier wins. Use the *WithOrigin variants to recover which namespace contributed the resolved descriptor — needed for hover provenance in protolsp and similar tools.
func NewResolver ¶
NewResolver creates a new Resolver for the given namespace.
func (*Resolver) FindDescriptorByName ¶
func (r *Resolver) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error)
FindDescriptorByName searches the namespace chain for a descriptor.
func (*Resolver) FindDescriptorByNameWithOrigin ¶ added in v0.71.0
func (r *Resolver) FindDescriptorByNameWithOrigin(name protoreflect.FullName) (protoreflect.Descriptor, string, error)
FindDescriptorByNameWithOrigin searches the namespace chain for a descriptor and returns the namespace ID that contributed it.
func (*Resolver) FindExtensionByName ¶
func (r *Resolver) FindExtensionByName(name protoreflect.FullName) (protoreflect.ExtensionType, error)
FindExtensionByName looks up an extension by name.
func (*Resolver) FindExtensionByNameWithOrigin ¶ added in v0.71.0
func (r *Resolver) FindExtensionByNameWithOrigin(name protoreflect.FullName) (protoreflect.ExtensionType, string, error)
FindExtensionByNameWithOrigin is FindExtensionByName with origin namespace.
func (*Resolver) FindExtensionByNumber ¶
func (r *Resolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
FindExtensionByNumber looks up an extension by the message it extends and its field number.
func (*Resolver) FindExtensionByNumberWithOrigin ¶ added in v0.71.0
func (r *Resolver) FindExtensionByNumberWithOrigin(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, string, error)
FindExtensionByNumberWithOrigin is FindExtensionByNumber with origin namespace.
func (*Resolver) FindFileByPath ¶
func (r *Resolver) FindFileByPath(path string) (protoreflect.FileDescriptor, error)
FindFileByPath searches the namespace chain for a file with the given path. Equivalent to FindFileByPathWithOrigin without the namespace ID.
func (*Resolver) FindFileByPathWithOrigin ¶ added in v0.71.0
func (r *Resolver) FindFileByPathWithOrigin(path string) (protoreflect.FileDescriptor, string, error)
FindFileByPathWithOrigin searches the namespace chain for a file with the given path and returns the namespace ID that contributed it.
func (*Resolver) FindMessageByName ¶
func (r *Resolver) FindMessageByName(name protoreflect.FullName) (protoreflect.MessageType, error)
FindMessageByName returns the message type for the given name. The returned type can be used to create dynamic messages.
func (*Resolver) FindMessageByNameWithOrigin ¶ added in v0.71.0
func (r *Resolver) FindMessageByNameWithOrigin(name protoreflect.FullName) (protoreflect.MessageType, string, error)
FindMessageByNameWithOrigin searches the namespace chain for a message type and returns the namespace ID that contributed it.
func (*Resolver) FindMessageByURL ¶
func (r *Resolver) FindMessageByURL(url string) (protoreflect.MessageType, error)
FindMessageByURL looks up a message type by its URL (e.g., "type.googleapis.com/acme.Config"). This enables use with protobuf Any types.
func (*Resolver) FindMessageByURLWithOrigin ¶ added in v0.71.0
func (r *Resolver) FindMessageByURLWithOrigin(url string) (protoreflect.MessageType, string, error)
FindMessageByURLWithOrigin is FindMessageByURL with origin namespace.
func (*Resolver) NewMessage ¶
NewMessage creates a dynamic message by fully-qualified name, searching across the namespace chain.
type SchemaResolver ¶
type SchemaResolver struct {
// contains filtered or unexported fields
}
SchemaResolver provides type resolution scoped to a single schema within a namespace. Use this when you need to resolve types from a specific schema rather than the entire namespace.
func NewSchemaResolver ¶
func NewSchemaResolver(ns *namespace.Namespace, schemaID string) *SchemaResolver
NewSchemaResolver creates a resolver scoped to a specific schema.
func (*SchemaResolver) FindMessageByName ¶
func (r *SchemaResolver) FindMessageByName(name protoreflect.FullName) (protoreflect.MessageType, error)
FindMessageByName returns the message type from the specific schema.
func (*SchemaResolver) NewMessage ¶
func (r *SchemaResolver) NewMessage(name protoreflect.FullName) (*dynamicpb.Message, error)
NewMessage creates a dynamic message from the specific schema.