mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-14 11:48:28 -04:00
351af50578
# Description of Changes Each reducer gets its arguments through an `ArgSource`, a Unix-file-like abstraction for streams of bytes. Prior to this commit, we had an ABI designed as if it could support other args sources, but it actually hardcoded the ID of the reducer args source, and errored elsewhere. This commit extends the `BytesSource` infrastructure to support other bytes sources. This will be useful for exposing JWT payloads and HTTP responses. No other `BytesSource` uses are actually included in this commit, only the infrastructure. This commit also defines a new host call, `bytes_source_remaining_length`. This is intended to allow callers to pre-allocate a buffer correctly sized to read the entire `BytesSource` all at once. The new host function is added to a new ABI minor version, 10.1, so that old SpacetimeDB hosts can detect and reject too-new compiled modules. I have added uses of this new function to `__call_reducer__` in both Rust and C#, even though it's not strictly necessary, and I haven't removed the loop which repeatedly calls `bytes_source_read` and grows the buffer. # API and ABI breaking changes Adds a new ABI minor version, `spacetime_10.1`. This means that old SpacetimeDB hosts will reject new compiled modules. # Expected complexity level and risk 2-ish? WASM ABI code is always fiddly, but this is a pretty simple case. # Testing - [x] New behavior and new host function are both hit through existing tests that instantiate modules and call reducers against them, so I believe automated testing is sufficient. --------- Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org> Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io> Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>