Skip to content

Commit

Permalink
chore: send bytes all at once
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon committed Jan 12, 2024
1 parent edd9715 commit 38760fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions google/cloud/alloydb/connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ def metadata_exchange(
# pack big-endian unsigned integer (4 bytes)
packed_len = struct.pack(">I", req.ByteSize())

# send metadata message length
sock.sendall(packed_len)
# send metadata request message
sock.sendall(req.SerializeToString())
# send metadata message length and request message
sock.sendall(packed_len + req.SerializeToString())

# form metadata exchange response
resp = connectorspb.MetadataExchangeResponse()
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,8 @@ def metadata_exchange(sock: ssl.SSLSocket) -> None:
# pack big-endian unsigned integer (4 bytes)
resp_len = struct.pack(">I", resp.ByteSize())

# send metadata response message length
sock.sendall(resp_len)
# send metadata request response message
sock.sendall(resp.SerializeToString())
# send metadata response length and response message
sock.sendall(resp_len + resp.SerializeToString())


class FakeConnectionInfo:
Expand Down

0 comments on commit 38760fa

Please sign in to comment.