Skip to content

[Brook K16] Added the Stream runtime to the C bridge. - #226

Closed
moetemp wants to merge 1 commit into
moe/brook/review/streams-k15-buffersfrom
moe/brook/review/streams-k16-c-bridge
Closed

moetemp wants to merge 1 commit into
moe/brook/review/streams-k15-buffersfrom
moe/brook/review/streams-k16-c-bridge

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds the Stream runtime of temporalio-streams to the C bridge, for the .NET SDK.

  • Five functions in src/streams.rs. temporal_core_stream_runtime_new builds the runtime of a kind (memory or redis) from its encoded config. temporal_core_stream_call runs a method on Core's Tokio runtime and calls back with the result, and the existing TemporalCoreCancellationToken cancels it with code 1. temporal_core_stream_call_sync and temporal_core_stream_call_static answer at once.
  • Inputs are TemporalCoreByteArrayRef. An empty one may have a null pointer.
  • A panic in a call answers as INTERNAL, since a panic can't cross the C ABI.
  • A call that ended before its cancel took effect still gives its result, since its effects happened. Outputs are TemporalCoreByteArray, which the caller frees with temporal_core_byte_array_free. A failure gives the gRPC code, the message and the encoded StreamErrorDetails.
  • Two features, both off by default. streams adds the optional path dependency on temporalio-streams. streams-redis adds the optional dependency on temporalio-streams-redis.
  • The functions exist in every build, so the header and .NET's Interop.cs don't change with the features. Without streams, a runtime fails to build with "This build has no Stream runtime". Without streams-redis, the redis kind fails the same way.
  • temporalio-streams-redis isn't on crates.io yet. So the workspace patches it to R4 (temporal-community/sdk-streams#4) by git rev, and patches that crate's temporalio-streams and temporalio-common to this workspace's copies. Each cargo call in this workspace now fetches that git repo, with the features off too.

Depends on #225 (K15). Review lane is the Rust reviewers.
Part of the Brook review series.

Spencer, can the C bridge take this optional dependency on the community Redis crate, behind streams-redis and off by default, as we discussed? Once the crate is on crates.io, the git patch goes and it's a plain crates.io dependency. The other choice is a .NET-owned wrapper cdylib that links this bridge as an rlib, but that renames the native library and changes much of Interop.cs.

Why?

.NET reaches Core only through this bridge, and a second native library couldn't share Core's Tokio runtime or its meter. So the .NET SDK's Stream runtime has to be in this cdylib. The official .NET build turns both features on, and other builds stay as they are.

How did you test it?

cargo clippy -- -D warnings and the bridge's streams tests pass with no features, with streams, and with streams,streams-redis, and the header is the same after each build. The tests call temporal_core_stream_call on the memory runtime through a callback, check a failure's code and details, cancel a 30 s read through a token, and call the sync and static functions. cargo doc passes with every feature.

@moetemp moetemp added the skip-changelog Changelog entry rides another PR label Oct 28, 2026
@moetemp
moetemp force-pushed the moe/brook/review/streams-k16-c-bridge branch from 03b90d5 to ede2244 Compare October 28, 2026 18:45
@moetemp
moetemp force-pushed the moe/brook/review/streams-k15-buffers branch from c843c16 to 6e9fe8f Compare October 28, 2026 18:45
@moetemp
moetemp force-pushed the moe/brook/review/streams-k16-c-bridge branch from ede2244 to d95e055 Compare October 28, 2026 18:59
@moetemp
moetemp force-pushed the moe/brook/review/streams-k15-buffers branch from 6e9fe8f to 2aa1859 Compare October 28, 2026 18:59
@moetemp
moetemp marked this pull request as draft October 28, 2026 21:55
@moetemp
moetemp force-pushed the moe/brook/review/streams-k15-buffers branch from 2aa1859 to 8bf74f3 Compare October 28, 2026 22:42
@moetemp
moetemp force-pushed the moe/brook/review/streams-k16-c-bridge branch 2 times, most recently from 72461b0 to a78ca55 Compare October 29, 2026 04:06
@moetemp
moetemp force-pushed the moe/brook/review/streams-k15-buffers branch 2 times, most recently from 515ba9c to aac18ed Compare October 29, 2026 08:37
@moetemp
moetemp force-pushed the moe/brook/review/streams-k16-c-bridge branch 2 times, most recently from 5248d63 to 5e0e4ef Compare October 29, 2026 09:17
The .NET SDK reaches Core through this bridge, so it gets the Stream runtime here, behind the optional `streams` and `streams-redis` features. The functions exist in every build, so the header stays the same.
@moetemp
moetemp force-pushed the moe/brook/review/streams-k15-buffers branch from 07f6bec to ebb26f8 Compare October 29, 2026 10:03
@moetemp
moetemp force-pushed the moe/brook/review/streams-k16-c-bridge branch from 5e0e4ef to 96fa426 Compare October 29, 2026 10:03
@moetemp

moetemp commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Parked. No SDK uses the Stream runtime through the C bridge yet. The branch stays, and this layer comes back with the .NET port.

@moetemp moetemp closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Changelog entry rides another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant