feat(router): 添加获取服务于所有用户的节点功能
修改 NodeRegistry 的 get_nodes_for_user 方法,除了获取显式映射到用户的节点外,现在还会包含服务于所有用户的节点(serves_users 为空的节点)。这确保了系统能正确处理全局可用的服务节点。
This commit is contained in:
parent
c0ecea9d3a
commit
ed7bbb1497
@ -161,7 +161,17 @@ class NodeRegistry:
|
||||
|
||||
def get_nodes_for_user(self, user_id: str) -> list[NodeConnection]:
|
||||
"""Get all nodes that serve a user."""
|
||||
node_ids = self._user_nodes.get(user_id, set())
|
||||
# Get nodes explicitly mapped to this user
|
||||
user_node_ids = self._user_nodes.get(user_id, set())
|
||||
|
||||
# Get nodes that serve all users (empty serves_users set)
|
||||
all_users_node_ids = set()
|
||||
for node_id, node in self._nodes.items():
|
||||
if not node.serves_users:
|
||||
all_users_node_ids.add(node_id)
|
||||
|
||||
# Combine both sets
|
||||
node_ids = user_node_ids | all_users_node_ids
|
||||
return [self._nodes[nid] for nid in node_ids if nid in self._nodes]
|
||||
|
||||
def get_active_node(self, user_id: str) -> Optional[NodeConnection]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user