Skip to content

Commit 6b460ff

Browse files
committed
chore(di): add dialog ttl (#63)
1 parent 673a3a0 commit 6b460ff

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

deploy/dev/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ services:
3636

3737
TTT_GEMINI_URL: https://my-openai-gemini-sigma-sandy.vercel.app
3838

39+
TTT_DIALOG_TTL: 259200 # 3 days
40+
3941
TTT_MATCHMAKING_MAX_WORKERS: 4
4042
TTT_MATCHMAKING_WORKER_MAX_USERS: 100
4143
TTT_MATCHMAKING_WORKER_CREATION_INTERVAL_SECONDS: 0.5

deploy/prod/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ services:
3636

3737
TTT_GEMINI_URL: ${GEMINI_URL}
3838

39+
TTT_DIALOG_TTL: 259200 # 3 days
40+
3941
TTT_MATCHMAKING_MAX_WORKERS: 4
4042
TTT_MATCHMAKING_WORKER_MAX_USERS: 100
4143
TTT_MATCHMAKING_WORKER_CREATION_INTERVAL_SECONDS: 0.5

src/ttt/infrastructure/pydantic_settings/envs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class Envs(BaseSettings):
2323

2424
gemini_url: str
2525

26+
dialog_ttl: int
27+
2628
matchmaking_max_workers: int
2729
matchmaking_worker_max_users: int
2830
matchmaking_worker_creation_interval_seconds: float

src/ttt/main/tg_bot/di.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
from ttt.application.user.view_other_user import ViewOtherUser
119119
from ttt.application.user.view_user import ViewUser
120120
from ttt.application.user.view_user_emojis import ViewUserEmojis
121+
from ttt.infrastructure.pydantic_settings.envs import Envs
121122
from ttt.infrastructure.pydantic_settings.secrets import Secrets
122123
from ttt.presentation.adapters.emojis import PictographsAsEmojis
123124
from ttt.presentation.adapters.game_views import (
@@ -163,8 +164,13 @@ class PresentationProvider(Provider):
163164
provide_event = from_context(TelegramObject | None, scope=Scope.REQUEST)
164165

165166
@provide(scope=Scope.APP)
166-
def provide_strage(self, redis: Redis) -> BaseStorage:
167-
return RedisStorage(redis, DefaultKeyBuilder(with_destiny=True))
167+
def provide_strage(self, redis: Redis, envs: Envs) -> BaseStorage:
168+
return RedisStorage(
169+
redis,
170+
DefaultKeyBuilder(with_destiny=True),
171+
state_ttl=envs.dialog_ttl,
172+
data_ttl=envs.dialog_ttl,
173+
)
168174

169175
@provide(scope=Scope.APP)
170176
def provide_bg_manager_factory(self, dp: Dispatcher) -> BgManagerFactory:

0 commit comments

Comments
 (0)