registry

package
v0.0.0-...-ee69469 Latest Latest
Warning

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

Go to latest
Published: May 5, 2016 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Description

type Description struct {
	Name     string
	Versions []int
}

Description gives the name and available versions in a registry.

type TypedNameVersion

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

TypedNameVersion is a registry that will allow you to register objects based on a name and version pair. The objects must be convertible to the Type defined when the registry was created. It will be cast during Register so you can be sure all objects returned from Get() are safe to TypeAssert to that type.

func NewTypedNameVersion

func NewTypedNameVersion(requiredType reflect.Type) *TypedNameVersion

NewTypedNameVersion creates a place to register your objects

func (*TypedNameVersion) Get

func (r *TypedNameVersion) Get(name string, version int) (interface{}, error)

Get returns the object for a single name and version. If the requested facade is not found, it returns error.NotFound

func (*TypedNameVersion) List

func (r *TypedNameVersion) List() []Description

List returns a slice describing each of the registered Facades.

func (*TypedNameVersion) Register

func (r *TypedNameVersion) Register(name string, version int, obj interface{}) error

Register records the factory that can be used to produce an instance of the facade at the supplied version. If the object being registered doesn't Implement the required Type, then an error is returned. An error is also returned if an object is already registered with the given name and version.

type Versions

type Versions map[int]interface{}

Versions maps concrete versions of the objects.

Jump to

Keyboard shortcuts

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