Skip to content

Commit

Permalink
and
Browse files Browse the repository at this point in the history
  • Loading branch information
a.rogov committed Feb 12, 2024
1 parent 70bd04b commit cd59afc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions overhave/storage/emulation_storage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
import logging
import socket
from typing import Any, List, cast
from typing import List, cast

import orjson
import sqlalchemy as sa
Expand Down Expand Up @@ -56,7 +56,7 @@ def has_running_emulation_with_user(self, test_user_id: int) -> bool:
class EmulationStorage(IEmulationStorage):
"""Class for emulation runs storage."""

def __init__(self, settings: OverhaveEmulationSettings, redis: "Redis[Any]"):
def __init__(self, settings: OverhaveEmulationSettings, redis: Redis):
self._redis = redis
self._settings = settings
self._redis.set(self._settings.redis_ports_key, orjson.dumps([]))
Expand Down
6 changes: 3 additions & 3 deletions overhave/transport/redis/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
logger = logging.getLogger(__name__)


def make_sentinel_master(settings: OverhaveRedisSentinelSettings) -> Redis: # type: ignore
def make_sentinel_master(settings: OverhaveRedisSentinelSettings) -> Redis:
logger.info("Connecting to redis through sentinel %s", settings.urls)
url_tuples = [(url.host, url.port) for url in settings.urls if url.host is not None and url.port is not None]
sentinel = Sentinel(url_tuples, socket_timeout=settings.socket_timeout.total_seconds(), retry_on_timeout=True)
return sentinel.master_for(settings.master_set, password=settings.password, db=settings.db)


def make_regular_redis(redis_settings: OverhaveRedisSettings) -> Redis: # type: ignore
def make_regular_redis(redis_settings: OverhaveRedisSettings) -> Redis:
return Redis.from_url(
redis_settings.url.human_repr(),
db=redis_settings.db,
socket_timeout=redis_settings.socket_timeout.total_seconds(),
)


def make_redis(redis_settings: BaseRedisSettings) -> Redis: # type: ignore # noqa: E501
def make_redis(redis_settings: BaseRedisSettings) -> Redis:
if isinstance(redis_settings, OverhaveRedisSentinelSettings):
return make_sentinel_master(redis_settings)

Expand Down

0 comments on commit cd59afc

Please sign in to comment.