registry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListTypes

func ListTypes(options ...Option) []reflect.Type

ListTypes queries the global component registry. Without any options, returns all types. This will copy the registry, so using the options to filter the returned types is preferred.

func RegisterType

func RegisterType(t reflect.Type)

RegisterType adds a type to the global component registry. This should not need to be called directly, as the component scanning mechanism should generate calls to this function.

Types

type Option

type Option func(reflect.Type) bool

Option to the ListTypes function.

func AssignableTo

func AssignableTo(intf reflect.Type) Option

AssignableTo provides the ability to filter registered types to those types that are assignable to the provided type, which will typically be a marker interface type, although any interface type will do.

func InPackage

func InPackage(pkg string) Option

InPackage provides the ability to filter registered types to those that are in a particular package or set of packages. If the package path ends with "/...", as in the standard go tools, this will search all packages rooted at the path before the "/...".

type Registry

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

Registry is captured as a type here so that you can stub out implementations of it in your tests.

func (*Registry) ListTypes

func (r *Registry) ListTypes(options ...Option) []reflect.Type

ListType lists the types that are stored in the registry.

func (*Registry) RegisterType

func (r *Registry) RegisterType(t reflect.Type)

RegisterType adds a type to the given registry.

Jump to

Keyboard shortcuts

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