Skip to content

Added count argument for better distribution. #85

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

Merged
merged 1 commit into from
Apr 23, 2025
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
4 changes: 4 additions & 0 deletions taskiq_redis/redis_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __init__(
maxlen: Optional[int] = None,
idle_timeout: int = 600000, # 10 minutes
unacknowledged_batch_size: int = 100,
xread_count: Optional[int] = 100,
additional_streams: Optional[Dict[str, str]] = None,
**connection_kwargs: Any,
) -> None:
Expand All @@ -189,6 +190,7 @@ def __init__(
Better to set it to a bigger value, to avoid unnecessary calls.
:param maxlen: sets the maximum length of the stream
trims (the old values of) the stream each time a new element is added
:param xread_count: number of messages to fetch from the stream at once.
:param additional_streams: additional streams to read from.
Each key is a stream name, value is a consumer id.
:param redeliver_timeout: time in ms to wait before redelivering a message.
Expand All @@ -211,6 +213,7 @@ def __init__(
self.additional_streams = additional_streams or {}
self.idle_timeout = idle_timeout
self.unacknowledged_batch_size = unacknowledged_batch_size
self.count = xread_count

async def _declare_consumer_group(self) -> None:
"""
Expand Down Expand Up @@ -276,6 +279,7 @@ async def listen(self) -> AsyncGenerator[AckableMessage, None]:
},
block=self.block,
noack=False,
count=self.count,
)
for _, msg_list in fetched:
for msg_id, msg in msg_list:
Expand Down