Made listeners only work for listenable connections.

This commit is contained in:
2025-04-07 20:32:16 +03:00
parent 51ebd6f204
commit b6bf6fa311
2 changed files with 6 additions and 2 deletions

View File

@@ -38,6 +38,10 @@ async def read_all_connections(db: AsyncSession):
result = await db.execute(select(Connection)) result = await db.execute(select(Connection))
return result.scalars().all() return result.scalars().all()
async def read_all_listenable_connection(db:AsyncSession):
result = await db.execute(select(Connection).filter(Connection.listen_updates == True))
return result.scalars().all()
async def create_connection(db: AsyncSession, connection: ConnectionCreate, user_id: int): async def create_connection(db: AsyncSession, connection: ConnectionCreate, user_id: int):
db_connection = Connection(**connection.model_dump(), owner_id=user_id) db_connection = Connection(**connection.model_dump(), owner_id=user_id)
db.add(db_connection) db.add(db_connection)

View File

@@ -30,9 +30,9 @@ async def shutdown():
async def mysql_streams_listeners_creator(): async def mysql_streams_listeners_creator():
from data.crud import read_all_connections from data.crud import read_all_listenable_connection
async with SessionLocal() as db: async with SessionLocal() as db:
connections = await read_all_connections(db=db) connections = await read_all_listenable_connection(db=db)
from utils.binlog import start_listeners from utils.binlog import start_listeners
start_listeners(connections=connections) start_listeners(connections=connections)