Open
Description
🚀 Feature Request: Batch Publish Support for Redis Stream
Summary
I'd like to propose adding batch publish functionality to the redis stream module. This feature would allow publishing multiple entries to the stream in a single publish operation.
Motivation
Batch publishing is a common and performance-critical feature in stream-oriented systems. It helps improve throughput and reduce network latency by minimizing the number of round-trips.
List
operations in redis module already support batching- redis streams are often used for high-throughput message ingestion, and batch support would significantly improve performance in such scenarios
Proposed Solution
I propose to add a method like:
pub_broker = RedisBroker("redis://127.0.0.1:6379")
# Stream without batch
queue = StreamSub("single")
# Stream with batch enabled
batch_stream = StreamSub("batch", batch=True)
@pub_broker.subscriber(stream=queue)
@pub_broker.publisher(stream=batch_stream)
async def m(msg):
return 1, 2, 3
@pub_broker.subscriber(stream=batch_stream)
async def resp(msg):
assert msg == [1, 2, 3] # Should pass!
await pub_broker.publish("", stream=queue)