registry

package
v0.2.29 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package registry operates the global registry of robotic parts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeregisterComponent added in v0.2.8

func DeregisterComponent(subtype resource.Subtype, model resource.Model)

DeregisterComponent removes a previously registered component.

func DeregisterResourceSubtype added in v0.2.8

func DeregisterResourceSubtype(subtype resource.Subtype)

DeregisterResourceSubtype removes a previously registered subtype.

func DeregisterService added in v0.2.8

func DeregisterService(subtype resource.Subtype, model resource.Model)

DeregisterService removes a previously registered service.

func DiscoveryFunctionLookup

func DiscoveryFunctionLookup(q discovery.Query) (discovery.Discover, bool)

DiscoveryFunctionLookup finds a discovery function registration for a given query.

func FindValidServiceModels added in v0.1.0

func FindValidServiceModels(rName resource.Name) []resource.Model

FindValidServiceModels returns a list of valid models for a specified service.

func RegisterComponent

func RegisterComponent(subtype resource.Subtype, model resource.Model, creator Component)

RegisterComponent register a creator to its corresponding component and model.

func RegisterDiscoveryFunction

func RegisterDiscoveryFunction(q discovery.Query, discover discovery.Discover)

RegisterDiscoveryFunction registers a discovery function for a given query.

func RegisterResourceSubtype

func RegisterResourceSubtype(subtype resource.Subtype, creator ResourceSubtype)

RegisterResourceSubtype register a ResourceSubtype to its corresponding component subtype.

func RegisterService

func RegisterService(subtype resource.Subtype, model resource.Model, creator Service)

RegisterService registers a service type to a registration.

func RegisteredComponents

func RegisteredComponents() map[string]Component

RegisteredComponents returns a copy of the registered components.

func RegisteredResourceSubtypes

func RegisteredResourceSubtypes() map[resource.Subtype]ResourceSubtype

RegisteredResourceSubtypes returns a copy of the registered resource subtypes.

func RegisteredServices

func RegisteredServices() map[string]Service

RegisteredServices returns a copy of the registered services.

Types

type Component

type Component struct {
	RegDebugInfo
	Constructor CreateComponent
	// TODO(RSDK-418): remove this legacy constructor once all components that use it no longer need to receive the entire robot.
	RobotConstructor CreateComponentWithRobot
}

Component stores a resource constructor (mandatory) and a Frame building function (optional).

func ComponentLookup

func ComponentLookup(subtype resource.Subtype, model resource.Model) *Component

ComponentLookup looks up a creator by the given subtype and model. nil is returned if there is no creator registered.

type CreateComponent

type CreateComponent func(ctx context.Context, deps Dependencies, config config.Component, logger golog.Logger) (interface{}, error)

A CreateComponent creates a resource from a collection of dependencies and a given config.

type CreateComponentWithRobot

type CreateComponentWithRobot func(ctx context.Context, r robot.Robot, config config.Component, logger golog.Logger) (interface{}, error)

A CreateComponentWithRobot creates a resource from a robot and a given config.

type CreateRPCClient

type CreateRPCClient func(ctx context.Context, conn rpc.ClientConn, name string, logger golog.Logger) interface{}

A CreateRPCClient will create the client for the resource.

type CreateReconfigurable

type CreateReconfigurable func(resource interface{}, name resource.Name) (resource.Reconfigurable, error)

A CreateReconfigurable makes a reconfigurable resource from a given resource.

type CreateService

type CreateService func(ctx context.Context, deps Dependencies, config config.Service, logger golog.Logger) (interface{}, error)

A CreateService creates a resource from a collection of dependencies and a given config.

type CreateServiceWithRobot added in v0.2.0

type CreateServiceWithRobot func(ctx context.Context, r robot.Robot, config config.Service, logger golog.Logger) (interface{}, error)

A CreateServiceWithRobot creates a resource from a robot and a given config.

type CreateStatus

type CreateStatus func(ctx context.Context, resource interface{}) (interface{}, error)

CreateStatus creates a status from a given resource. The return type is expected to be comprised of string keys (or it should be possible to decompose it into string keys) and values comprised of primitives, list of primitives, maps with string keys (or at least can be decomposed into one), or lists of the aforementioned type of maps. Results with other types of data are not guaranteed.

type Dependencies

type Dependencies map[resource.Name]interface{}

Dependencies is a map of resources that a component requires for creation.

type DependencyNotReadyError

type DependencyNotReadyError struct {
	Name string
}

A DependencyNotReadyError is used whenever we reference a dependency that has not been constructed and registered yet.

func (*DependencyNotReadyError) Error

func (e *DependencyNotReadyError) Error() string

type ReconfigurableComponent added in v0.2.8

type ReconfigurableComponent interface {
	// Reconfigure reconfigures the resource
	Reconfigure(ctx context.Context, cfg config.Component, deps Dependencies) error
}

ReconfigurableComponent is implemented when component/service of a robot is reconfigurable.

type ReconfigurableService added in v0.2.8

type ReconfigurableService interface {
	// Reconfigure reconfigures the resource
	Reconfigure(ctx context.Context, cfg config.Service, deps Dependencies) error
}

ReconfigurableService is implemented when component/service of a robot is reconfigurable.

type RegDebugInfo

type RegDebugInfo struct {
	RegistrarLoc string
}

RegDebugInfo represents some runtime information about the registration used for debugging purposes.

type RegisterSubtypeRPCService

type RegisterSubtypeRPCService func(ctx context.Context, rpcServer rpc.Server, subtypeSvc subtype.Service) error

A RegisterSubtypeRPCService will register the subtype service to the grpc server.

type ResourceSubtype

type ResourceSubtype struct {
	Reconfigurable        CreateReconfigurable
	Status                CreateStatus
	RegisterRPCService    RegisterSubtypeRPCService
	RPCServiceDesc        *grpc.ServiceDesc
	ReflectRPCServiceDesc *desc.ServiceDescriptor `copy:"shallow"`
	RPCClient             CreateRPCClient

	// MaxInstance sets a limit on the number of this subtype allowed on a robot.
	// If MaxInstance is not set then it will default to 0 and there will be no limit.
	MaxInstance int
}

ResourceSubtype stores subtype-specific functions and clients.

func ResourceSubtypeLookup

func ResourceSubtypeLookup(subtype resource.Subtype) *ResourceSubtype

ResourceSubtypeLookup looks up a ResourceSubtype by the given subtype. nil is returned if there is None.

type Service

type Service struct {
	RegDebugInfo
	Constructor           CreateService
	AttributeMapConverter config.AttributeMapConverter
	// This is a legacy constructor for default services
	RobotConstructor CreateServiceWithRobot
}

Service stores a Service constructor (mandatory) and an attribute converter.

func ServiceLookup

func ServiceLookup(subtype resource.Subtype, model resource.Model) *Service

ServiceLookup looks up a service registration by the given type. nil is returned if there is no registration.

type SubtypeGrpc

type SubtypeGrpc struct{}

SubtypeGrpc stores functions necessary for a resource subtype to be accessible through grpc.

Jump to

Keyboard shortcuts

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