pw_grpc: Support fragmented gRPC messages if an allocator is provided

Previously, gRPC messages that were fragmented across multiple HTTP2
DATA frames were unsupported, as the reassembly process could require
buffering up to the maximum message size *per stream*.

This commit adds support for fragmented messages, taking in an optional
pw::allocator::Allocator which is used to allocate a buffer for
fragmented message reassembly. This allows consumers of pw_grpc to
determine the fragmentation allocation strategy that works best for
their purpose: e.g. by providing an allocator that allows a single
message to be buffered at a time, or limits the total amount of
additional overhead.

Bug: b/323924487
Test:
  Using the Python gRPC library, which aggressively fragments messages
  when the flow control window is small, I sent a long stream of
  messages that got fragmented and successfully reassembled. Some of
  these messages fragmented the initial length-prefix too, which also
  worked correctly.
Change-Id: Ie43ee0326ef38cbe826486bf07bec6ecc68d67af
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/204431
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Austin Foxley <afoxley@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Eli Lipsitz <elipsitz@google.com>
5 files changed
tree: a3b08f404f6b585d1106886fa2c8069cdabeaaf6
  1. .allstar/
  2. .github/
  3. .vscode/
  4. build_overrides/
  5. docker/
  6. docs/
  7. kudzu/
  8. pw_alignment/
  9. pw_allocator/
  10. pw_analog/
  11. pw_android_toolchain/
  12. pw_arduino_build/
  13. pw_assert/
  14. pw_assert_basic/
  15. pw_assert_log/
  16. pw_assert_tokenized/
  17. pw_assert_zephyr/
  18. pw_async/
  19. pw_async2/
  20. pw_async2_basic/
  21. pw_async2_epoll/
  22. pw_async_basic/
  23. pw_base64/
  24. pw_bloat/
  25. pw_blob_store/
  26. pw_bluetooth/
  27. pw_bluetooth_hci/
  28. pw_bluetooth_profiles/
  29. pw_bluetooth_proxy/
  30. pw_bluetooth_sapphire/
  31. pw_boot/
  32. pw_boot_cortex_m/
  33. pw_build/
  34. pw_build_android/
  35. pw_build_info/
  36. pw_build_mcuxpresso/
  37. pw_bytes/
  38. pw_channel/
  39. pw_checksum/
  40. pw_chre/
  41. pw_chrono/
  42. pw_chrono_embos/
  43. pw_chrono_freertos/
  44. pw_chrono_rp2040/
  45. pw_chrono_stl/
  46. pw_chrono_threadx/
  47. pw_chrono_zephyr/
  48. pw_cli/
  49. pw_compilation_testing/
  50. pw_config_loader/
  51. pw_console/
  52. pw_containers/
  53. pw_cpu_exception/
  54. pw_cpu_exception_cortex_m/
  55. pw_cpu_exception_risc_v/
  56. pw_crypto/
  57. pw_digital_io/
  58. pw_digital_io_linux/
  59. pw_digital_io_mcuxpresso/
  60. pw_digital_io_rp2040/
  61. pw_docgen/
  62. pw_doctor/
  63. pw_emu/
  64. pw_env_setup/
  65. pw_env_setup_zephyr/
  66. pw_file/
  67. pw_format/
  68. pw_function/
  69. pw_fuzzer/
  70. pw_grpc/
  71. pw_hdlc/
  72. pw_hex_dump/
  73. pw_i2c/
  74. pw_i2c_linux/
  75. pw_i2c_mcuxpresso/
  76. pw_i2c_rp2040/
  77. pw_ide/
  78. pw_interrupt/
  79. pw_interrupt_cortex_m/
  80. pw_interrupt_xtensa/
  81. pw_interrupt_zephyr/
  82. pw_intrusive_ptr/
  83. pw_json/
  84. pw_kvs/
  85. pw_libc/
  86. pw_libcxx/
  87. pw_log/
  88. pw_log_android/
  89. pw_log_basic/
  90. pw_log_null/
  91. pw_log_rpc/
  92. pw_log_string/
  93. pw_log_tokenized/
  94. pw_log_zephyr/
  95. pw_malloc/
  96. pw_malloc_freelist/
  97. pw_malloc_freertos/
  98. pw_metric/
  99. pw_minimal_cpp_stdlib/
  100. pw_module/
  101. pw_multibuf/
  102. pw_multisink/
  103. pw_package/
  104. pw_perf_test/
  105. pw_persistent_ram/
  106. pw_polyfill/
  107. pw_preprocessor/
  108. pw_presubmit/
  109. pw_protobuf/
  110. pw_protobuf_compiler/
  111. pw_random/
  112. pw_result/
  113. pw_ring_buffer/
  114. pw_router/
  115. pw_rpc/
  116. pw_rpc_transport/
  117. pw_rust/
  118. pw_sensor/
  119. pw_snapshot/
  120. pw_software_update/
  121. pw_span/
  122. pw_spi/
  123. pw_spi_linux/
  124. pw_spi_mcuxpresso/
  125. pw_spi_rp2040/
  126. pw_status/
  127. pw_stm32cube_build/
  128. pw_stream/
  129. pw_stream_shmem_mcuxpresso/
  130. pw_stream_uart_linux/
  131. pw_stream_uart_mcuxpresso/
  132. pw_string/
  133. pw_symbolizer/
  134. pw_sync/
  135. pw_sync_baremetal/
  136. pw_sync_embos/
  137. pw_sync_freertos/
  138. pw_sync_stl/
  139. pw_sync_threadx/
  140. pw_sync_zephyr/
  141. pw_sys_io/
  142. pw_sys_io_ambiq_sdk/
  143. pw_sys_io_arduino/
  144. pw_sys_io_baremetal_lm3s6965evb/
  145. pw_sys_io_baremetal_stm32f429/
  146. pw_sys_io_emcraft_sf2/
  147. pw_sys_io_mcuxpresso/
  148. pw_sys_io_rp2040/
  149. pw_sys_io_stdio/
  150. pw_sys_io_stm32cube/
  151. pw_sys_io_zephyr/
  152. pw_system/
  153. pw_target_runner/
  154. pw_thread/
  155. pw_thread_embos/
  156. pw_thread_freertos/
  157. pw_thread_stl/
  158. pw_thread_threadx/
  159. pw_thread_zephyr/
  160. pw_tls_client/
  161. pw_tls_client_boringssl/
  162. pw_tls_client_mbedtls/
  163. pw_tokenizer/
  164. pw_toolchain/
  165. pw_toolchain_bazel/
  166. pw_trace/
  167. pw_trace_tokenized/
  168. pw_transfer/
  169. pw_uart/
  170. pw_unit_test/
  171. pw_unit_test_zephyr/
  172. pw_varint/
  173. pw_watch/
  174. pw_web/
  175. pw_work_queue/
  176. seed/
  177. targets/
  178. third_party/
  179. ts/
  180. zephyr/
  181. .bazelignore
  182. .bazelrc
  183. .bazelversion
  184. .black.toml
  185. .clang-format
  186. .clang-tidy
  187. .eslintrc.cjs
  188. .git-blame-ignore-revs
  189. .gitattributes
  190. .gitignore
  191. .gn
  192. .mypy.ini
  193. .prettierignore
  194. .prettierrc.cjs
  195. .pw_ide.yaml
  196. .pylintrc
  197. activate.bat
  198. Android.bp
  199. AUTHORS
  200. bootstrap.bat
  201. bootstrap.sh
  202. BUILD.bazel
  203. BUILD.gn
  204. BUILDCONFIG.gn
  205. CMakeLists.txt
  206. jest.config.ts
  207. Kconfig.zephyr
  208. LICENSE
  209. modules.gni
  210. OWNERS
  211. package-lock.json
  212. package.json
  213. pigweed.json
  214. PIGWEED_MODULES
  215. README.md
  216. rollup.config.js
  217. tsconfig.json
  218. WORKSPACE
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links