protobuf: google.golang.org/protobuf/reflect/protoregistry Index | Files

package protoregistry

import "google.golang.org/protobuf/reflect/protoregistry"

Package protoregistry provides data structures to register and lookup protobuf descriptor types.

The Files registry contains file descriptors and provides the ability to iterate over the files or lookup a specific descriptor within the files. Files only contains protobuf descriptors and has no understanding of Go type information that may be associated with each descriptor.

The Types registry contains descriptor types for which there is a known Go type associated with that descriptor. It provides the ability to iterate over the registered types or lookup a type by name.

Index

Package Files

registry.go

Variables

var NotFound = errors.New("not found")

NotFound is a sentinel error value to indicate that the type was not found.

Since registry lookup can happen in the critical performance path, resolvers must return this exact error value, not an error wrapping it.

type ExtensionTypeResolver Uses

type ExtensionTypeResolver interface {
    // FindExtensionByName looks up a extension field by the field's full name.
    // Note that this is the full name of the field as determined by
    // where the extension is declared and is unrelated to the full name of the
    // message being extended.
    //
    // This returns (nil, NotFound) if not found.
    FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)

    // FindExtensionByNumber looks up a extension field by the field number
    // within some parent message, identified by full name.
    //
    // This returns (nil, NotFound) if not found.
    FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
}

ExtensionTypeResolver is an interface for looking up extensions.

A compliant implementation must deterministically return the same type if no error is encountered.

The Types type implements this interface.

type Files Uses

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

Files is a registry for looking up or iterating over files and the descriptors contained within them. The Find and Range methods are safe for concurrent use.

var GlobalFiles *Files = new(Files)

GlobalFiles is a global registry of file descriptors.

func (*Files) FindDescriptorByName Uses

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

FindDescriptorByName looks up a descriptor by the full name.

This returns (nil, NotFound) if not found.

func (*Files) FindFileByPath Uses

func (r *Files) FindFileByPath(path string) (protoreflect.FileDescriptor, error)

FindFileByPath looks up a file by the path.

This returns (nil, NotFound) if not found.

func (*Files) NumFiles Uses

func (r *Files) NumFiles() int

NumFiles reports the number of registered files.

func (*Files) NumFilesByPackage Uses

func (r *Files) NumFilesByPackage(name protoreflect.FullName) int

NumFilesByPackage reports the number of registered files in a proto package.

func (*Files) RangeFiles Uses

func (r *Files) RangeFiles(f func(protoreflect.FileDescriptor) bool)

RangeFiles iterates over all registered files while f returns true. The iteration order is undefined.

func (*Files) RangeFilesByPackage Uses

func (r *Files) RangeFilesByPackage(name protoreflect.FullName, f func(protoreflect.FileDescriptor) bool)

RangeFilesByPackage iterates over all registered files in a given proto package while f returns true. The iteration order is undefined.

func (*Files) RegisterFile Uses

func (r *Files) RegisterFile(file protoreflect.FileDescriptor) error

RegisterFile registers the provided file descriptor.

If any descriptor within the file conflicts with the descriptor of any previously registered file (e.g., two enums with the same full name), then the file is not registered and an error is returned.

It is permitted for multiple files to have the same file path.

type MessageTypeResolver Uses

type MessageTypeResolver interface {
    // FindMessageByName looks up a message by its full name.
    // E.g., "google.protobuf.Any"
    //
    // This return (nil, NotFound) if not found.
    FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error)

    // FindMessageByURL looks up a message by a URL identifier.
    // See documentation on google.protobuf.Any.type_url for the URL format.
    //
    // This returns (nil, NotFound) if not found.
    FindMessageByURL(url string) (protoreflect.MessageType, error)
}

MessageTypeResolver is an interface for looking up messages.

A compliant implementation must deterministically return the same type if no error is encountered.

The Types type implements this interface.

type Types Uses

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

Types is a registry for looking up or iterating over descriptor types. The Find and Range methods are safe for concurrent use.

var GlobalTypes *Types = new(Types)

GlobalTypes is the registry used by default for type lookups unless a local registry is provided by the user.

func (*Types) FindEnumByName Uses

func (r *Types) FindEnumByName(enum protoreflect.FullName) (protoreflect.EnumType, error)

FindEnumByName looks up an enum by its full name. E.g., "google.protobuf.Field.Kind".

This returns (nil, NotFound) if not found.

func (*Types) FindExtensionByName Uses

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

FindExtensionByName looks up a extension field by the field's full name. Note that this is the full name of the field as determined by where the extension is declared and is unrelated to the full name of the message being extended.

This returns (nil, NotFound) if not found.

func (*Types) FindExtensionByNumber Uses

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

FindExtensionByNumber looks up a extension field by the field number within some parent message, identified by full name.

This returns (nil, NotFound) if not found.

func (*Types) FindMessageByName Uses

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

FindMessageByName looks up a message by its full name, e.g. "google.protobuf.Any".

This returns (nil, NotFound) if not found.

func (*Types) FindMessageByURL Uses

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

FindMessageByURL looks up a message by a URL identifier. See documentation on google.protobuf.Any.type_url for the URL format.

This returns (nil, NotFound) if not found.

func (*Types) NumEnums Uses

func (r *Types) NumEnums() int

NumEnums reports the number of registered enums.

func (*Types) NumExtensions Uses

func (r *Types) NumExtensions() int

NumExtensions reports the number of registered extensions.

func (*Types) NumExtensionsByMessage Uses

func (r *Types) NumExtensionsByMessage(message protoreflect.FullName) int

NumExtensionsByMessage reports the number of registered extensions for a given message type.

func (*Types) NumMessages Uses

func (r *Types) NumMessages() int

NumMessages reports the number of registered messages.

func (*Types) RangeEnums Uses

func (r *Types) RangeEnums(f func(protoreflect.EnumType) bool)

RangeEnums iterates over all registered enums while f returns true. Iteration order is undefined.

func (*Types) RangeExtensions Uses

func (r *Types) RangeExtensions(f func(protoreflect.ExtensionType) bool)

RangeExtensions iterates over all registered extensions while f returns true. Iteration order is undefined.

func (*Types) RangeExtensionsByMessage Uses

func (r *Types) RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool)

RangeExtensionsByMessage iterates over all registered extensions filtered by a given message type while f returns true. Iteration order is undefined.

func (*Types) RangeMessages Uses

func (r *Types) RangeMessages(f func(protoreflect.MessageType) bool)

RangeMessages iterates over all registered messages while f returns true. Iteration order is undefined.

func (*Types) RegisterEnum Uses

func (r *Types) RegisterEnum(et protoreflect.EnumType) error

RegisterEnum registers the provided enum type.

If a naming conflict occurs, the type is not registered and an error is returned.

func (*Types) RegisterExtension Uses

func (r *Types) RegisterExtension(xt protoreflect.ExtensionType) error

RegisterExtension registers the provided extension type.

If a naming conflict occurs, the type is not registered and an error is returned.

func (*Types) RegisterMessage Uses

func (r *Types) RegisterMessage(mt protoreflect.MessageType) error

RegisterMessage registers the provided message type.

If a naming conflict occurs, the type is not registered and an error is returned.

Package protoregistry imports 8 packages (graph) and is imported by 45 packages. Updated 2020-08-08. Refresh now. Tools for package owners.