Skip to content

feat(server): add coroutine streaming and gRPC reactors - #321

Merged
MisterVVP merged 2 commits into
release/v0.6.0from
feat/async-server-streaming
Nov 1, 2026
Merged

MisterVVP merged 2 commits into
release/v0.6.0from
feat/async-server-streaming

Conversation

@MisterVVP

Copy link
Copy Markdown
Owner

Summary

Closes #169.

Adds opt-in coroutine server streaming for SendStreamingMessage and SubscribeToTask to the existing Boost.Asio executor and native gRPC callback service. Applications await owned event writes and return a terminal result. Existing synchronous executors, sessions, dispatchers and transport registrations remain source-compatible.

  • AsyncDispatcher::DispatchStream reuses the [Enhancement]: Add opt-in async unary server execution and cancellation #268 request context, terminal arbitration, admission limits, validation, authentication and interceptors. After hooks run once at stream completion. Shared authorization helpers recheck stored task visibility before each event, and write failures remain authoritative even if an application ignores them.
  • Native gRPC stream reactors retain each protobuf through OnWriteDone, permit one outstanding write, defer Finish until that write completes, and delete themselves in OnDone. Cancellation/deadlines and host shutdown use the existing request lifecycle. A stalled native write is cancelled so it cannot hold host drain; its application context retains the shutdown outcome while the wire may report CANCELLED. Pending coroutine cleanup retains its admission reservation. The async path has no blocking Next, watcher, polling or per-stream SDK worker.
  • Async task subscriptions share the synchronous publication core, snapshot, event order and terminal rules. Their buffers are bounded; overflow explicitly fails the slow subscriber without holding publishers or other consumers. Startup/store work in the TCK fixture uses fixed backend workers, while live delivery suspends on publication and write demand. This does not provide asynchronous database I/O.
  • The unified async TCK setup now advertises gRPC streaming. Documentation and the installed-package example cover opt-in registration, event ownership, demand, cancellation and shutdown. CI includes the streaming tests in its sanitizer profiles. HTTP/SSE scheduling remains [Enhancement]: Deliver a reusable opt-in event-driven HTTP server runtime #270.

Authorship and AI usage

  • Contains substantive content written by a human
  • Contains substantive content generated by an AI agent

Testing

  • Canonical PostgreSQL-enabled ./scripts/verify_changes.sh: 985 tests passed, zero failures (two expected TLS-without-SUT skips).

  • Exact repository formatting and explicit ./scripts/run_clang_tidy.sh build with LLVM 19: passed across 71 production and 89 test/example translation units. The local runner executes the unchanged checks for every translation unit in parallel and reuses successful results only when tool, command, source and header content fingerprints match.

  • Clang 19 AddressSanitizer + UndefinedBehaviorSanitizer: 29 streaming checks passed, including native RPCs, SDK-client interoperability, slow-reader cancellation, non-reading-client host drain, and the independent-thread publication/cancellation race.

  • ThreadSanitizer: 17 streaming checks passed, without suppressions.

  • Official TCK start/run/stop flow, both in-memory and PostgreSQL stores:

    Setup Passed Skipped Executed failures
    Synchronous, all three transports — per store 249 16 0
    Coroutine unary + streaming, gRPC — per store 83 182 0

    The coroutine setup executes 15 more tests than the prior unary-only setup. Upstream registry requirements without tests remain explicit coverage gaps; passing executable tests does not claim complete registered-requirement coverage.

  • Required gRPC + HTTP/JSON performance smoke: 54 scenarios, zero errors.

  • mdbook build book: passed. Python tooling pip-audit: no known vulnerabilities. Dependency manifests are unchanged.

Reproducible c64 evidence

async_stream_execution_evidence 64 compares synchronous and coroutine gRPC subscriptions with the same publication core, metadata and two events per stream. Both modes use one channel and synchronous client reads, without adding a client thread per stream. A Linux Debug run using GCC 15.3, gRPC 1.51.1 and Boost 1.92.0 produced:

Mode Application threads Process threads before → pending First-event p95 Completion p95 Errors
Synchronous 64 9 → 73 0.35 ms 7.78 ms 0
Coroutine 2 12 → 12 0.33 ms 2.71 ms 0

The coroutine completion result meets the 10 ms target for this workload. Measurements include shared-runner scheduling and sequential client draining; they are not a general latency guarantee. The executable and reproduction instructions are included under tests/ and book/src/server/async-streaming.md.

Checklist

  • ./scripts/verify_changes.sh passed locally
  • Docs updated if behavior changed

@MisterVVP MisterVVP added the AI agent AI agent contribution label Oct 31, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Oct 31, 2026
@MisterVVP MisterVVP added enhancement New feature or request performance Performance improvement related tasks based on benchmark results. Performance tests changes. labels Oct 31, 2026
Extract focused assertion helpers so streaming tests stay within the cognitive complexity limit with CI GoogleTest headers. Poll initial metadata before waiting for server progress in the unread-stream tests, and use the supported minimum HTTP/2 lookahead buffer.
@MisterVVP MisterVVP linked an issue Nov 1, 2026 that may be closed by this pull request
12 tasks
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T10:17:32.089801Z 907d8b7 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 907d8b7a5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP
MisterVVP merged commit 2416a29 into release/v0.6.0 Nov 1, 2026
23 checks passed
@MisterVVP
MisterVVP deleted the feat/async-server-streaming branch November 1, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution enhancement New feature or request performance Performance improvement related tasks based on benchmark results. Performance tests changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant