Skip to content
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

[FAL-2030] fix: add missing commands to prefix #1376

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions kombu/transport/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ class GlobalKeyPrefixMixin:
"LLEN",
"LPUSH",
"PUBLISH",
"RPUSH",
"RPOP",
"SADD",
"SREM",
"SET",
"SMEMBERS",
"ZADD",
Expand All @@ -206,6 +209,7 @@ class GlobalKeyPrefixMixin:
]

PREFIXED_COMPLEX_COMMANDS = {
"DEL": {"args_start": 0, "args_end": None},
"BRPOP": {"args_start": 0, "args_end": -1},
"EVALSHA": {"args_start": 2, "args_end": 3},
}
Expand All @@ -222,13 +226,10 @@ def _prefix_args(self, args):
args_end = self.PREFIXED_COMPLEX_COMMANDS[command]["args_end"]

pre_args = args[:args_start] if args_start > 0 else []
post_args = []

if args_end is not None:
post_args = args[args_end:]
elif args_end < 0:
post_args = args[len(args):]
else:
post_args = []

args = pre_args + [
self.global_keyprefix + str(arg)
Expand Down
15 changes: 15 additions & 0 deletions t/unit/transport/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,21 @@ def test_prefix_simple_args(self):
f"{self.global_keyprefix}fake_key"
]

def test_prefix_delete_args(self):
prefixed_args = self.mixin._prefix_args([
"DEL",
"fake_key",
"fake_key2",
"fake_key3"
])

assert prefixed_args == [
"DEL",
f"{self.global_keyprefix}fake_key",
f"{self.global_keyprefix}fake_key2",
f"{self.global_keyprefix}fake_key3",
]

def test_prefix_brpop_args(self):
prefixed_args = self.mixin._prefix_args([
"BRPOP",
Expand Down