entity

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateEntities

func ActivateEntities(collection Collection, conf *config.Configuration, log *zerolog.Logger) error

ActivateEntities activates the given entities.

func GetIDs

func GetIDs(collection Collection) []string

GetIDs gets a list of entity IDs.

func GetNames

func GetNames(collection Collection) []string

GetNames gets a list of entity names.

Types

type Collection

type Collection interface {
	// Entities returns a vector of entities within the collection.
	Entities() []Entity
}

Collection is an interface for entity collections.

type Entity

type Entity interface {
	// GetID returns the ID of the entity.
	GetID() string
	// GetName returns the display name of the entity.
	GetName() string

	// Activate activates the entity.
	Activate(conf *config.Configuration, log *zerolog.Logger) error
}

Entity is the base interface for all Mentix entities.

type Registry

type Registry struct {
	Entities map[string]Entity
}

Registry represents a simple id->entity map.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a new entity registry.

func (*Registry) FindEntities

func (r *Registry) FindEntities(ids []string, mustExist bool, anyRequired bool) ([]Entity, error)

FindEntities returns all entities matching the provided IDs. If an entity with a certain ID doesn't exist and mustExist is true, an error is returned.

func (*Registry) Register

func (r *Registry) Register(entity Entity)

Register registers a new entity.

Jump to

Keyboard shortcuts

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