Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move redis max connections to .env #48

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ ADMIN_LOGS_CHAT_ID=-1234 # tg chat id for admin logs
VK_TOKEN=fppgmdbgonj

# ocr
MYSTIC_TOKEN=444
MYSTIC_TOKEN=444

REDIS_MAX_CONNECTIONS=128
2 changes: 2 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Config(BaseSettings):

MYSTIC_TOKEN: str | None = None

REDIS_MAX_CONNECTIONS: int = 128

# @model_validator(mode="after")
# def validate_sentry_non_local(self) -> "Config":
# if self.ENVIRONMENT.is_deployed and not self.SENTRY_DSN:
Expand Down
4 changes: 3 additions & 1 deletion src/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from src.models import CustomModel

pool = aioredis.ConnectionPool.from_url(
str(settings.REDIS_URL), max_connections=32, decode_responses=True
str(settings.REDIS_URL),
max_connections=settings.REDIS_MAX_CONNECTIONS,
decode_responses=True,
)
redis_client = aioredis.Redis(connection_pool=pool)

Expand Down
4 changes: 3 additions & 1 deletion start-polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

if __name__ == "__main__":
pool = aioredis.ConnectionPool.from_url(
str(settings.REDIS_URL), max_connections=10, decode_responses=True
str(settings.REDIS_URL),
max_connections=settings.REDIS_MAX_CONNECTIONS,
decode_responses=True
)
redis.redis_client = aioredis.Redis(connection_pool=pool)

Expand Down
Loading