Skip to content

Commit

Permalink
Merge pull request #9 from wakscord/feature/remove-del-active-nodes
Browse files Browse the repository at this point in the history
비활성화 노드 제외 해주는 책임 status_notifier로 위임
  • Loading branch information
cdw8431 authored Aug 5, 2023
2 parents 2b70eff + a01e1e2 commit 67e91c3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
6 changes: 0 additions & 6 deletions app/domain/node/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ async def is_active(self, node_id: str) -> bool:
async def get_all_nodes(self) -> list[str]:
raise NotImplementedError

async def delete_node(self, node_id: str) -> None:
raise NotImplementedError


class NodeRedisRepository(NodeRepository):
_NODE_SERVERS_KEY = "node_servers"
Expand All @@ -25,6 +22,3 @@ async def is_active(self, node_id: str) -> bool:

async def get_all_nodes(self) -> list[str]:
return await self._session.hkeys(self._NODE_SERVERS_KEY)

async def delete_node(self, node_id: str) -> None:
await self._session.hdel(self._NODE_SERVERS_KEY, node_id)
5 changes: 0 additions & 5 deletions app/domain/node/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ def __init__(self, node_repo: NodeRepository):
async def get_active_nodes(self) -> list[str]:
all_nodes: set[str] = set(await self._node_repo.get_all_nodes())
active_nodes: set[str] = {node for node in all_nodes if await self._node_repo.is_active(node)}

should_delete_nodes = all_nodes - active_nodes
for node in should_delete_nodes:
await self._node_repo.delete_node(node)

return list(active_nodes)

0 comments on commit 67e91c3

Please sign in to comment.