-
Notifications
You must be signed in to change notification settings - Fork 80
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
Refactor Redis keys to avoid duplicate string literals #309
base: master
Are you sure you want to change the base?
Conversation
tests/test_base.py
Outdated
@@ -127,7 +138,7 @@ def test_simple_task(self): | |||
|
|||
Worker(self.tiger).run(once=True) | |||
self._ensure_queues(queued={"default": 0}) | |||
assert not self.conn.exists("t:task:%s" % task["id"]) | |||
assert not self.conn.exists(f"{REDIS_PREFIX}:{TASK}:%s" % task["id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep these literals unchanged in tests to make it clearer what these keys look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to almost only change tests (which we probably don't want to change) and not the literals in the actual feature code.
Thanks for the review. |
Not a problem! Thanks for looking into this! There are a lot of places that need changes. A couple of examples:
There's probably a couple dozen lines that need an update. |
@neob91-close, |
tasktiger/constants.py
Outdated
EXECUTIONS_COUNT = "executions_count" | ||
|
||
|
||
QUEUED = "queued" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are already defined in tasktiger._internal
.
What's more, these definitions aren't even used.
We should get rid of them.
tasktiger/constants.py
Outdated
@@ -0,0 +1,11 @@ | |||
# constants pertaining to Redis keys | |||
REDIS_PREFIX = "t" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used, nor is it needed (it's configurable, and the default value is defined in tasktiger.tasktiger
.
tasktiger/constants.py
Outdated
@@ -0,0 +1,11 @@ | |||
# constants pertaining to Redis keys | |||
REDIS_PREFIX = "t" | |||
TASK = "task" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move these definitions to tasktiger._internal
for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some more changes necessary.
By the way, sorry it took me so long to get back to you.
873d95d
to
b5d0ffe
Compare
Hi @neob91-close , |
Description
Replaced string literals in the Redis keys to constants.
Resolves #255