Skip to content

Fix #499: add use_namespace_prefix_keys option to enable message keys that have unhashed namespace prefix#842

Open
JoaoAlmeida20 wants to merge 3 commits intoBogdanp:masterfrom
JoaoAlmeida20:result-message-namespace
Open

Fix #499: add use_namespace_prefix_keys option to enable message keys that have unhashed namespace prefix#842
JoaoAlmeida20 wants to merge 3 commits intoBogdanp:masterfrom
JoaoAlmeida20:result-message-namespace

Conversation

@JoaoAlmeida20
Copy link

Addresses #499, based on #615 PR, which was closed for being a breaking change, making it necessary to guard it behind a flag or otherwise guaranteeing compatibility with old style keys, which didn't end up being addressed at the time. Here, the new behavior only happens if we set use_namespace_prefix_keys to True in the ResultsBackend instance.

I didn't start a discussion since the PR is based on an existing PR and the feedback it had already gotten, apologies if that was skipping a step.

@LincolnPuzey
Copy link
Collaborator

LincolnPuzey commented Mar 15, 2026

Hi @JoaoAlmeida20, skipping the conversation is ok since there is the existing issue/PR/feedback, I'll have a look, thanks

*,
namespace: str = "dramatiq-results",
encoder: typing.Optional[Encoder] = None,
use_namespace_prefix_keys: bool = False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new parameter needs to be added to __init__ of the RedisBackend and MemcachedBackend classes that subclass this.

"actor_name": message.actor_name,
"message_id": message.message_id,
}
hashed_key = hashlib.md5(message_key.encode("utf-8")).hexdigest()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to still md5 the part after the namespace? #615 Didn't do that.

Feels like it would be nicer to not use any MD5? That way you have different useful prefixes to work with in the final key:

namespace:
namespace:queue:
namespace:queue:actor:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that does sound better. I considered it briefly, but I didn't notice the message_key went unhashed in #615 already. Changed it in de987eb

…none of the key components are md5 hashed, add use_namespace_prefix_keys to RedisBackend and MemcachedBackend inits
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.

2 participants