(
command_encoded: bytes,
to_send_ops_encoded: list[bytes],
to_send_ns_encoded: list[bytes],
ack: bool,
buf: _BytesIO,
)
| 991 | |
| 992 | |
| 993 | def _client_construct_op_msg( |
| 994 | command_encoded: bytes, |
| 995 | to_send_ops_encoded: list[bytes], |
| 996 | to_send_ns_encoded: list[bytes], |
| 997 | ack: bool, |
| 998 | buf: _BytesIO, |
| 999 | ) -> int: |
| 1000 | # Write flags |
| 1001 | flags = b"\x00\x00\x00\x00" if ack else b"\x02\x00\x00\x00" |
| 1002 | buf.write(flags) |
| 1003 | |
| 1004 | # Type 0 Section |
| 1005 | buf.write(b"\x00") |
| 1006 | buf.write(command_encoded) |
| 1007 | |
| 1008 | # Type 1 Section for ops |
| 1009 | buf.write(b"\x01") |
| 1010 | size_location = buf.tell() |
| 1011 | # Save space for size |
| 1012 | buf.write(b"\x00\x00\x00\x00") |
| 1013 | buf.write(b"ops\x00") |
| 1014 | # Write all the ops documents |
| 1015 | for op_encoded in to_send_ops_encoded: |
| 1016 | buf.write(op_encoded) |
| 1017 | resume_location = buf.tell() |
| 1018 | # Write type 1 section size |
| 1019 | length = buf.tell() |
| 1020 | buf.seek(size_location) |
| 1021 | buf.write(_pack_int(length - size_location)) |
| 1022 | buf.seek(resume_location) |
| 1023 | |
| 1024 | # Type 1 Section for nsInfo |
| 1025 | buf.write(b"\x01") |
| 1026 | size_location = buf.tell() |
| 1027 | # Save space for size |
| 1028 | buf.write(b"\x00\x00\x00\x00") |
| 1029 | buf.write(b"nsInfo\x00") |
| 1030 | # Write all the nsInfo documents |
| 1031 | for ns_encoded in to_send_ns_encoded: |
| 1032 | buf.write(ns_encoded) |
| 1033 | # Write type 1 section size |
| 1034 | length = buf.tell() |
| 1035 | buf.seek(size_location) |
| 1036 | buf.write(_pack_int(length - size_location)) |
| 1037 | |
| 1038 | return length |
| 1039 | |
| 1040 | |
| 1041 | def _client_batched_op_msg_impl( |
no test coverage detected