def _configure_test_server(server: grpc.Server, port: int, secure_mode: bool, server_id: str) -> None: test_pb2_grpc.add_TestServiceServicer_to_server( TestService(server_id, socket.gethostname()), server) listen_address = f"{_LISTEN_HOST}:{port}" if not secure_mode: server.add_insecure_port(listen_address) else: logger.info("Running with xDS Server credentials") server_fallback_creds = grpc.insecure_server_credentials() server_creds = grpc.xds_server_credentials(server_fallback_creds) server.add_secure_port(listen_address, server_creds)
def _configure_greeter_server(server: grpc.Server, port: int, secure_mode: bool, hostname) -> None: # Add the application servicer to the server. helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(hostname), server) listen_address = f"{_LISTEN_HOST}:{port}" if not secure_mode: server.add_insecure_port(listen_address) else: # Use xDS credentials. logger.info("Running with xDS Server credentials") # Fall back to insecure credentials. server_fallback_creds = grpc.insecure_server_credentials() server_creds = grpc.xds_server_credentials(server_fallback_creds) server.add_secure_port(listen_address, server_creds)