Coverage for volexpcsi/server.py: 92%
24 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-28 12:48 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-28 12:48 +0000
1import grpc
2from concurrent import futures
3from grpc_health.v1 import health, health_pb2, health_pb2_grpc
4from grpc_reflection.v1alpha import reflection
5from logging import getLogger
6from . import api
7from .identity import VolExpIdentity
8from .controller import VolExpControl
9from .node import VolExpNode
11_log = getLogger(__name__)
14def boot_server(hostport: str, config: dict, cred: grpc.ServerCredentials | None = None):
15 _log.info("booting server at %s", hostport)
16 server = grpc.server(futures.ThreadPoolExecutor(max_workers=config.get("max_workers")))
17 health_pb2_grpc.add_HealthServicer_to_server(health.HealthServicer(), server)
18 api.add_IdentityServicer_to_server(VolExpIdentity(config), server)
19 api.add_ControllerServicer_to_server(VolExpControl(config), server)
20 api.add_NodeServicer_to_server(VolExpNode(config), server)
21 SERVICE_NAMES = (
22 health_pb2.DESCRIPTOR.services_by_name["Health"].full_name,
23 reflection.SERVICE_NAME,
24 api.DESCRIPTOR.services_by_name["Identity"].full_name,
25 api.DESCRIPTOR.services_by_name["Controller"].full_name,
26 # api.DESCRIPTOR.services_by_name["GroupController"].full_name,
27 # api.DESCRIPTOR.services_by_name["SnapshotMetadata"].full_name,
28 api.DESCRIPTOR.services_by_name["Node"].full_name,
29 )
30 reflection.enable_server_reflection(SERVICE_NAMES, server)
31 if cred: 31 ↛ 32line 31 didn't jump to line 32 because the condition on line 31 was never true
32 port = server.add_secure_port(hostport, cred)
33 else:
34 port = server.add_insecure_port(hostport)
35 server.start()
36 return port, server