registry

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package registry indexes generated protobuf-go-lite message constructors and their statically generated custom options.

Index

Constants

This section is empty.

Variables

ErrNotFound is returned when a message type is not registered.

Functions

func NewByName

func NewByName(name string) (protobuf_go_lite.Message, bool)

NewByName constructs a message from the default registry by full name.

func NewByTypeURL

func NewByTypeURL(url string) (protobuf_go_lite.Message, bool)

NewByTypeURL constructs a message from the default registry by type URL.

func Range

func Range(fn func(Entry) bool)

Range calls fn for each entry in the default registry.

func Register

func Register(e Entry)

Register adds e to the default registry.

Types

type Entry

type Entry struct {
	// FullName is the fully qualified protobuf message name.
	FullName string
	// TypeURL is the canonical google.protobuf.Any type URL.
	TypeURL string
	// New constructs an empty message.
	New func() protobuf_go_lite.Message
	// Options contains the message's flattened custom options.
	Options []Option
}

Entry describes one generated protobuf message type.

func All

func All() []Entry

All returns a snapshot of the default registry.

func (Entry) Option

func (e Entry) Option(name string) (string, bool)

Option returns the first value registered under name.

type Option

type Option struct {
	// Name is the fully qualified option name followed by its message field path.
	Name string
	// Values contains repeated values in declaration order.
	Values []string
}

Option contains the flattened values of one custom message option.

type Registry

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

Registry indexes message constructors by full name and type URL.

func Default

func Default() *Registry

Default returns the registry populated by generated init functions.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an empty message registry.

func (*Registry) All

func (r *Registry) All() []Entry

All returns a full-name-sorted snapshot of the registered entries.

func (*Registry) FindMessageByURL

func (r *Registry) FindMessageByURL(url string) (func() protobuf_go_lite.Message, error)

FindMessageByURL returns the constructor named by url.

func (*Registry) NewByName

func (r *Registry) NewByName(name string) (protobuf_go_lite.Message, bool)

NewByName constructs the message registered under its full protobuf name.

func (*Registry) NewByTypeURL

func (r *Registry) NewByTypeURL(url string) (protobuf_go_lite.Message, bool)

NewByTypeURL constructs the message named by url.

func (*Registry) Range

func (r *Registry) Range(fn func(Entry) bool)

Range calls fn for each entry in full-name order until fn returns false. The callback runs without holding the registry lock.

func (*Registry) Register

func (r *Registry) Register(e Entry)

Register adds e to the registry. It copies the option metadata and panics if FullName is empty, New is nil, or FullName is already registered.

Jump to

Keyboard shortcuts

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