objects

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2017 License: BSD-3-Clause Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const (
	TagSingleton = "singleton"
	TagExtpoint  = "extpoint"
	TagConfig    = "config"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Object   *Object
	Name     string
	Config   bool
	Extpoint bool
	Tag      string
	// contains filtered or unexported fields
}

Field represents metadata of a field in an Object value's struct.

type Object

type Object struct {
	Value   interface{}
	Name    string
	Fields  map[string]*Field
	Enabled bool
	PkgPath string
	// contains filtered or unexported fields
}

Object represents an object and its metadata in a registry

func New

func New(v interface{}, name string) *Object

New creates a new Object by value and name

func (*Object) Assign

func (o *Object) Assign(field string, obj *Object) bool

Assign will set a named field of the object value if it has not already been assigned. It will not assign to fields marked as extension points. It will return true if the assignment is successful.

func (*Object) FQN

func (o *Object) FQN() string

FQN returns a fully qualified name for a unique object in a registry

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Registry is a container for objects.

func (*Registry) Enabled

func (r *Registry) Enabled() []*Object

Enabled returns all enabled objects.

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (*Object, error)

Lookup will attempt to find an object in the registry... 1. if it matches the object FQN exactly 2. if it matches a single object Name 3. if it matches a single object by package path suffix

func (*Registry) Objects

func (r *Registry) Objects() []*Object

Objects returns all registered objects.

func (*Registry) Register

func (r *Registry) Register(objects ...*Object) error

Register adds objects to the registry.

func (*Registry) Reload

func (r *Registry) Reload() error

Reload will go over all objects in the registry and attempt to populate fields with com struct tags with other objects in the registry.

func (*Registry) SetEnabled

func (r *Registry) SetEnabled(fqn string, enabled bool)

SetEnabled will set whether an object is enabled.

Jump to

Keyboard shortcuts

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