Made listeners only work for listenable connections.
This commit is contained in:
@@ -38,6 +38,10 @@ async def read_all_connections(db: AsyncSession):
|
||||
result = await db.execute(select(Connection))
|
||||
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):
|
||||
db_connection = Connection(**connection.model_dump(), owner_id=user_id)
|
||||
db.add(db_connection)
|
||||
|
||||
@@ -30,9 +30,9 @@ async def shutdown():
|
||||
|
||||
|
||||
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:
|
||||
connections = await read_all_connections(db=db)
|
||||
connections = await read_all_listenable_connection(db=db)
|
||||
|
||||
from utils.binlog import start_listeners
|
||||
start_listeners(connections=connections)
|
||||
|
||||
Reference in New Issue
Block a user