Skip to content

Conversation

@vishesh10
Copy link
Contributor

Description

Replaced string literals in the Redis keys to constants.

Resolves #255

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"])
Copy link
Contributor

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.

Copy link
Contributor

@neob91-close neob91-close left a 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.

@vishesh10
Copy link
Contributor Author

Thanks for the review.
If tests are skipped then there are very few changes in the code.

@neob91-close
Copy link
Contributor

neob91-close commented Nov 14, 2023

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.

@vishesh10
Copy link
Contributor Author

@neob91-close,
Reverted the test cases and added changes at the appropriate places.
Thanks

EXECUTIONS_COUNT = "executions_count"


QUEUED = "queued"
Copy link
Contributor

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.

@@ -0,0 +1,11 @@
# constants pertaining to Redis keys
REDIS_PREFIX = "t"
Copy link
Contributor

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.

@@ -0,0 +1,11 @@
# constants pertaining to Redis keys
REDIS_PREFIX = "t"
TASK = "task"
Copy link
Contributor

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?

Copy link
Contributor

@neob91-close neob91-close left a 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.

@vishesh10
Copy link
Contributor Author

Hi @neob91-close ,
Done changes as per the suggestions.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor keys to avoid duplicate string literals

2 participants