viam.rpc.server

Attributes

LOGGER

Classes

Server

gRPC Server

Module Contents

viam.rpc.server.LOGGER
class viam.rpc.server.Server(resources: List[viam.resource.base.ResourceBase], *, module_service: viam.module.service.ModuleRPCService | None = None)[source]

Bases: viam.resource.manager.ResourceManager

gRPC Server

services
async serve(host: str | None = 'localhost', port: int | None = 9090, log_level: int | None = logging.INFO, *, path: str | None = None)[source]

Server the gRPC server on the provided host and port

Parameters:
  • host (Optional[str], optional) – Desired hostname of the server. Defaults to “localhost”.

  • port (Optional[int], optional) – Desired port of the server. Defaults to 9090.

  • log_level (Optional[int], optional) – The minimum log level. To not receive any logs, set to None. Defaults to logging.INFO.

  • path (Optional[str], optional) – UNIX socket path. Takes precedence over host and port if set. Defaults to None.

classmethod create_and_serve(components: List[viam.resource.base.ResourceBase], host: str | None = 'localhost', port: int | None = 9090, log_level: int = logging.INFO, *, path: str | None = None)[source]
Async:

Convenience method to create and start the server.

Parameters:
  • components (List[ComponentBase]) – List of components to manage

  • host (str, optional) – Desired hostname. Defaults to “localhost”.

  • port (int, optional) – Desired port. Defaults to 9090.

  • log_level (int, optional) – The minimum log level. To not receive any logs, set to None. Defaults to logging.INFO

  • path (Optional[str], optional) – UNIX socket path. Takes precedence over host and port if set. Defaults to None.

async close()

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