Skip to content

Commit 45070a1

Browse files
feat: add redis_username configuration variable
1 parent 3f151db commit 45070a1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sketch_map_tool/config.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class Config(BaseSettings):
3838
redis_host: str = "localhost"
3939
redis_port: str = "6379"
4040
redis_db_number: str = ""
41-
redis_password: str | None = None
41+
redis_password: str = ""
42+
redis_username: str = ""
4243
user_agent: str = "sketch-map-tool"
4344
weights_dir: str = str(get_project_root() / "weights") # TODO: make this a Path
4445
wms_layers_esri_world_imagery: str = "world_imagery"
@@ -73,15 +74,16 @@ def result_backend(self) -> str:
7374
@computed_field
7475
@property
7576
def broker_url(self) -> str:
76-
if self.redis_password is None:
77-
return "redis://{host}:{port}/{db_number}".format(
77+
if self.redis_password or self.redis_username:
78+
return "redis://{username}:{password}@{host}:{port}/{db_number}".format(
79+
username=self.redis_username,
80+
password=self.redis_password,
7881
host=self.redis_host,
7982
port=self.redis_port,
8083
db_number=self.redis_db_number,
8184
)
8285
else:
83-
return "redis://:{password}@{host}:{port}/{db_number}".format(
84-
password=self.redis_password,
86+
return "redis://{host}:{port}/{db_number}".format(
8587
host=self.redis_host,
8688
port=self.redis_port,
8789
db_number=self.redis_db_number,

0 commit comments

Comments
 (0)