Skip to content

Commit 38760fa

Browse files
chore: send bytes all at once
1 parent edd9715 commit 38760fa

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

google/cloud/alloydb/connector/connector.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,8 @@ def metadata_exchange(
233233
# pack big-endian unsigned integer (4 bytes)
234234
packed_len = struct.pack(">I", req.ByteSize())
235235

236-
# send metadata message length
237-
sock.sendall(packed_len)
238-
# send metadata request message
239-
sock.sendall(req.SerializeToString())
236+
# send metadata message length and request message
237+
sock.sendall(packed_len + req.SerializeToString())
240238

241239
# form metadata exchange response
242240
resp = connectorspb.MetadataExchangeResponse()

tests/unit/mocks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,8 @@ def metadata_exchange(sock: ssl.SSLSocket) -> None:
256256
# pack big-endian unsigned integer (4 bytes)
257257
resp_len = struct.pack(">I", resp.ByteSize())
258258

259-
# send metadata response message length
260-
sock.sendall(resp_len)
261-
# send metadata request response message
262-
sock.sendall(resp.SerializeToString())
259+
# send metadata response length and response message
260+
sock.sendall(resp_len + resp.SerializeToString())
263261

264262

265263
class FakeConnectionInfo:

0 commit comments

Comments
 (0)