SpaceProbe1 / services /connection_registry.py
a9's picture
Upload 26 files
9793e68 verified
from typing import Dict
from services.connection_manager import RepoConnection
import asyncio
class ConnectionRegistry:
def __init__(self):
self.connections: Dict[str, RepoConnection] = {}
def register(self, repo):
if repo.id in self.connections: return
conn = RepoConnection(repo.id, repo.namespace, repo.repo)
self.connections[repo.id] = conn
asyncio.create_task(conn._listen_events())
def unregister(self, repo_id: str):
if conn := self.connections.pop(repo_id, None):
conn.stop()
registry = ConnectionRegistry()