generated from geekiot/python-template
Add [redis]: move redis to database package
This commit is contained in:
parent
563668dabe
commit
05486d6f4b
5 changed files with 8 additions and 10 deletions
|
|
@ -14,7 +14,7 @@ from .middlewares import connect_middlewares
|
|||
@loguru_logger.catch
|
||||
async def start_bot(
|
||||
bot_token: str,
|
||||
redis_client: Redis,
|
||||
redis_protocol: Redis,
|
||||
session_maker: async_sessionmaker,
|
||||
) -> None:
|
||||
"""
|
||||
|
|
@ -28,7 +28,7 @@ async def start_bot(
|
|||
bot = Bot(bot_token)
|
||||
|
||||
dispatcher = Dispatcher(
|
||||
storage=RedisStorage(redis=redis_client),
|
||||
storage=RedisStorage(redis=redis_protocol),
|
||||
)
|
||||
|
||||
connect_middlewares(
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@ __all__ = [
|
|||
"drop_db",
|
||||
"engine",
|
||||
"session_maker",
|
||||
"redis_protocol",
|
||||
]
|
||||
|
||||
|
||||
from .models import Student, TelegramUser, UniversityMember
|
||||
from .session import (
|
||||
from .postgres import (
|
||||
create_db,
|
||||
drop_db,
|
||||
engine,
|
||||
session_maker,
|
||||
)
|
||||
from .redis import protocol as redis_protocol
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
__all__ = ["client"]
|
||||
|
||||
|
||||
from redis.asyncio.client import Redis
|
||||
|
||||
from config import settings
|
||||
|
||||
client = Redis(
|
||||
protocol = Redis(
|
||||
host=settings.redis_host,
|
||||
port=settings.redis_port,
|
||||
)
|
||||
|
|
@ -2,8 +2,7 @@ import asyncio
|
|||
|
||||
from bot import start_bot
|
||||
from config import configure_logger, settings
|
||||
from database import create_db, engine, session_maker
|
||||
from redis_client import client as redis_client
|
||||
from database import create_db, engine, redis_protocol, session_maker
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
|
|
@ -22,7 +21,7 @@ async def main() -> None:
|
|||
|
||||
await start_bot(
|
||||
bot_token=settings.bot_token,
|
||||
redis_client=redis_client,
|
||||
redis_protocol=redis_protocol,
|
||||
session_maker=session_maker,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue