viam.resource.manager

Attributes

LOGGER

ResourceType

Classes

ResourceManager

Registry containing all components registered to this server.

Module Contents

viam.resource.manager.LOGGER
viam.resource.manager.ResourceType
class viam.resource.manager.ResourceManager(components: List[viam.resource.base.ResourceBase] = [])[source]

Registry containing all components registered to this server.

resources: Dict[viam.proto.common.ResourceName, viam.resource.base.ResourceBase]
register(resource: viam.resource.base.ResourceBase)[source]

Register a new resource with the registry. Resources may not have the same name. If a resource is remote and the short name is unique, save a short name version.

Raises:
Parameters:

resource (ResourceBase) – The resource to register

get_resource(of_type: Type[ResourceType], name: viam.proto.common.ResourceName) ResourceType[source]

Return a resource from the registry. If a unique short name version is given, return a remote resource with the name.

Parameters:
Raises:

ResourceNotFoundError – Error if resource with the given type and name does not exist in the registry

Returns:

The resource

Return type:

ResourceType

async remove_resource(name: viam.proto.common.ResourceName)[source]

Remove the resource with the specified `ResourceName`.

Parameters:

name (viam.proto.common.ResourceName) – The ResourceName of the resource

async close()[source]

Close the resourcce manager by removing all resources. Please note that any errors will not raise an exception. Errors will still be logged.