Skip to content

Commit

Permalink
black it
Browse files Browse the repository at this point in the history
  • Loading branch information
devppjr committed Dec 29, 2023
1 parent b494e3c commit 2c011ab
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tc_redis/base_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class RedisBaseStorage:

single_node_storage = None
cluster_storage = None
sentinel_storage = None
Expand All @@ -29,7 +28,9 @@ def __init__(self, context, storage_type):
"db": self.context.config.get("REDIS_STORAGE_SERVER_DB"),
"host": self.context.config.get("REDIS_STORAGE_SERVER_HOST"),
"instances": self.context.config.get(
"REDIS_CLUSTER_STORAGE_STARTUP_INSTANCES" if self.context.config.get("REDIS_STORAGE_MODE") == CLUSTER else "REDIS_SENTINEL_STORAGE_INSTANCES"
"REDIS_CLUSTER_STORAGE_STARTUP_INSTANCES"
if self.context.config.get("REDIS_STORAGE_MODE") == CLUSTER
else "REDIS_SENTINEL_STORAGE_INSTANCES"
),
"master_instance": self.context.config.get(
"REDIS_SENTINEL_STORAGE_MASTER_INSTANCE"
Expand All @@ -56,7 +57,9 @@ def __init__(self, context, storage_type):
"db": self.context.config.get("REDIS_RESULT_STORAGE_SERVER_DB"),
"host": self.context.config.get("REDIS_RESULT_STORAGE_SERVER_HOST"),
"instances": self.context.config.get(
"REDIS_CLUSTER_RESULT_STORAGE_STARTUP_INSTANCES" if self.context.config.get("REDIS_RESULT_STORAGE_MODE") == CLUSTER else "REDIS_SENTINEL_RESULT_STORAGE_INSTANCES"
"REDIS_CLUSTER_RESULT_STORAGE_STARTUP_INSTANCES"
if self.context.config.get("REDIS_RESULT_STORAGE_MODE") == CLUSTER
else "REDIS_SENTINEL_RESULT_STORAGE_INSTANCES"
),
"master_instance": self.context.config.get(
"REDIS_SENTINEL_RESULT_STORAGE_MASTER_INSTANCE"
Expand Down Expand Up @@ -138,8 +141,18 @@ def connect_redis_single_node(self):
)

def connect_redis_cluster(self):
instances_split = [tuple(instance.strip().split(":")) for instance in self.storage_values[self.storage_type]["instances"].split(",")]
instances = list(map(lambda x: ClusterNode(x[0], int(x[1] if len(x) == 2 else 6379)), instances_split))
instances_split = [
tuple(instance.strip().split(":"))
for instance in self.storage_values[self.storage_type]["instances"].split(
","
)
]
instances = list(
map(
lambda x: ClusterNode(x[0], int(x[1] if len(x) == 2 else 6379)),
instances_split,
)
)

if self.storage_values[self.storage_type]["password"] is None:
return RedisCluster(
Expand Down

0 comments on commit 2c011ab

Please sign in to comment.