self._controller.get_all_endpoints.remote()):
raise KeyError(f"Endpoint "{endpoint_name}" does not exist.")
routers = list(ray.get(self._controller.get_routers.remote()).values())
current_node_id = ray.get_runtime_context().node_id.hex()
try:
router_chosen = next(
filter(lambda r: get_node_id_for_actor(r) == current_node_id,
routers))
except StopIteration:
logger.warning(
f"When getting a handle for {endpoint_name}, Serve can"t find "
"a router on the same node. Serve will use a random router.")