Skip to content
Merged
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
8 changes: 6 additions & 2 deletions src/rsmq/cmd/delete_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def exec_command(self):
"""Exec Command"""
result = self.get_transaction().execute()

if int(result[0]) == 1 and int(result[1]) > 0:
# 1 key deleted from zset
# 3 keys deleted from hash (message itself, receive count, first receive field)
if int(result[0]) == 1 and int(result[1]) == 3:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is there a scenario where result[1] > 0 but not 3?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, unless the number of keys stored per message in the hash changes. From what I could tell, the message, receive count, and first receive are always there, so if there are not deleted then there would be some sort of problem. That was my thought process around this.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

makes sense.... BTW, it is out as v0.6.1 🤞🏻

return True

return False
Expand All @@ -31,7 +33,9 @@ def get_transaction(self):
queue_base = self.queue_base
queue_key = self.queue_key
message_id = self.get_id

# decode to string when provided as bytes
if isinstance(message_id, bytes):
message_id = message_id.decode('utf-8')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

to avoid issues with tx.zrem() we may want to adjust the message id specifically for generated rc/fr keys - but it seems to work fine as-is

tx = client.pipeline(transaction=True)
tx.zrem(queue_base, message_id)
tx.hdel(queue_key, message_id, "%s:rc" % message_id, "%s:fr" % message_id)
Expand Down
Loading