fix: include topic frame in KV events replay response (#45177)
Signed-off-by: RishabhSaini <rishabhsaini01@gmail.com>
This commit is contained in:
@@ -97,11 +97,12 @@ class MockSubscriber:
|
||||
for endpoint in pub_endpoints:
|
||||
self.sub.connect(endpoint)
|
||||
|
||||
# Set up replay sockets if provided
|
||||
# Set up replay sockets if provided.
|
||||
# DEALER allows receiving multiple replies per request.
|
||||
self.replay_sockets = []
|
||||
if replay_endpoints:
|
||||
for replay_endpoint in replay_endpoints:
|
||||
replay = self.ctx.socket(zmq.REQ)
|
||||
replay = self.ctx.socket(zmq.DEALER)
|
||||
replay.connect(replay_endpoint)
|
||||
self.replay_sockets.append(replay)
|
||||
|
||||
@@ -132,7 +133,9 @@ class MockSubscriber:
|
||||
if socket_idx >= len(self.replay_sockets):
|
||||
raise ValueError(f"Invalid socket index {socket_idx}")
|
||||
|
||||
self.replay_sockets[socket_idx].send(start_seq.to_bytes(8, "big"))
|
||||
self.replay_sockets[socket_idx].send_multipart(
|
||||
[b"", start_seq.to_bytes(8, "big")]
|
||||
)
|
||||
|
||||
def receive_replay(self, socket_idx: int = 0) -> list[tuple[int, SampleBatch]]:
|
||||
"""Receive replayed messages from a specific replay socket"""
|
||||
@@ -148,12 +151,16 @@ class MockSubscriber:
|
||||
if not replay_socket.poll(1000):
|
||||
break
|
||||
|
||||
# DEALER receives [empty_delim, topic, seq, payload]
|
||||
frames = replay_socket.recv_multipart()
|
||||
if not frames or not frames[-1]:
|
||||
if frames and frames[0] == b"":
|
||||
frames = frames[1:]
|
||||
if len(frames) != 3 or not frames[-1]:
|
||||
# End of replay marker
|
||||
break
|
||||
|
||||
seq_bytes, payload = frames
|
||||
topic, seq_bytes, payload = frames
|
||||
assert topic == self.topic_bytes
|
||||
seq = int.from_bytes(seq_bytes, "big")
|
||||
data = self.decoder.decode(payload)
|
||||
replayed.append((seq, data))
|
||||
|
||||
Reference in New Issue
Block a user