nanover.core.grpc_server module
Module providing a wrapper around the running of GRPC servers.
- class nanover.core.grpc_server.GrpcServer(*, address: str, port: int, max_workers=128)
Bases:
object
A base class for running GRPC servers that handles the starting and closing of the underlying server.
- Parameters:
address – The IP address at which to run the server.
port – The port on which to run the server.
- add_service(service)
Add a gRPC service to this server.
- Parameters:
service – The gRPC service to add, must have the method to add the gRPC service as the attribute add_to_server_method.
- property address
Get the address that this server is or was provided at.
- property address_and_port: Tuple[str, int]
Gets the address and port that the server is or was provided on as a tuple.
- Returns:
The address and port that the server is or was provided on as a tuple.
- close()
Stops the server.
Inheritors of this class should override this method with routines to stop services that are running.
- property port
Get the port that the server is or was provided on. This is 0 if a port was unable to be chosen.
- setup_services()
Inheritors of this class should setup any services they run.
- nanover.core.grpc_server.get_requested_port_or_default(port: int | None, default: int) int
Returns the port you asked for, or the default one is port is None.