-
Notifications
You must be signed in to change notification settings - Fork 0
feat: pochta-worker #53
Conversation
niqzart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хоба
app/pochta/dependencies/redis_dep.py
Outdated
|
|
||
| import redis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: from-импорт
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Актуально везде
app/pochta/dependencies/redis_dep.py
Outdated
|
|
||
| RedisConnectionDep = Annotated[redis.asyncio.Redis, Depends(get_redis_connection)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Это просто RedisConnection
app/pochta/models.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: это не модель, это схема
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Вытащить это в common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(if-minor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вместо common пока просто вытащил в workers/pochta_rds.py
app/pochta/routes/pochta_mub.py
Outdated
|
|
||
| @router.get("/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: И всё же это POST
app/pochta/worker.py
Outdated
|
|
||
| BLOCK_TIME_MS: int = 2000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Final[int]
app/pochta/main.py
Outdated
| @redis_consumer( | ||
| stream_name=REDIS_POCHTA_STREAM, consumer_name="pochta_consumer", model=PochtaModel | ||
| ) | ||
| async def process_email_message(message: PochtaModel) -> None: | ||
| print(f"Message: {message}") # noqa T201 # temporary print |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue(обсудили голосом): Это невозможно импортировать, надо чего-то подумать
app/pochta/main.py
Outdated
| @asynccontextmanager | ||
| async def lifespan() -> AsyncIterator[None]: | ||
| tasks = [] | ||
| for worker in redis_consumers: | ||
| worker_task = asyncio.create_task(worker.run()) | ||
| tasks.append(worker_task) | ||
| yield | ||
| for task in tasks: | ||
| task.cancel() | ||
|
|
||
|
|
||
| mub_router = APIRouterExt(prefix="/mub", dependencies=[MUBProtection]) | ||
| mub_router.include_router(pochta_mub.router, prefix="/pochta") | ||
|
|
||
| api_router = APIRouterExt() | ||
| api_router.include_router(mub_router) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: Обычно оно в обратном порядке
app/pochta/worker.py
Outdated
|
|
||
| redis_consumers: list[RedisStreamConsumer] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue(обсудили голосом): уф
8603fba to
f654fd2
Compare
f654fd2 to
ba5c2a3
Compare
5f85af2 to
ba5c2a3
Compare
|
Закрыто в связи с переносом репозитория и изменения реализации в пользу использования FastStream |
No description provided.