Skip to content

refactor(http): dispatch default streams asynchronously - #230

Merged
MisterVVP merged 1 commit into
dev-make-libcurl-streaming-cancellation-event-drivenfrom
dev-complete-async-shared-http-streaming
Aug 29, 2026
Merged

MisterVVP merged 1 commit into
dev-make-libcurl-streaming-cancellation-event-drivenfrom
dev-complete-async-shared-http-streaming

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • Replace the per-stream blocked worker model with an asynchronous, reactor-driven streaming path so idle default HTTP/JSON and JSON-RPC streams no longer consume a dedicated executor worker.
  • Ensure no arbitrary user/observer code executes on the libcurl reactor thread and provide per-stream serialized dispatch so slow observers cannot stall unrelated streams.
  • Make libcurl callback lifetime and cancellation semantics safe for an asynchronous transfer state and preserve the existing synchronous Client::StreamRequest() API as a waiting wrapper.
  • Document the new callback-dispatch model in docs/streaming-usage.md.

Description

  • Added a shared stream callback dispatch runtime: a fixed StreamDispatchExecutor with a small pool and per-stream SerialStreamDispatch queues to serialize per-stream callbacks off the reactor thread. (new code in src/http/http_client.cpp).
  • Introduced heap-owned, lifetime-safe AsyncStreamState that holds easy-handle, headers, buffers, callback wrappers, cancellation registration, and a transfer lifetime object so libcurl callbacks reference only heap-owned state that stays valid until reactor completion. (new code in src/http/http_client.cpp).
  • Extended a2a::http::Client with StartStreamRequest(...) to register an asynchronous reactor transfer and invoke a StreamCompletion callback on completion; made the original synchronous StreamRequest(...) a small wrapper that waits on StartStreamRequest. (changes in include/a2a/http/http_client.h and src/http/http_client.cpp).
  • Made the libcurl reactor CurlStreamReactor::Transfer report completions via an on_complete callback and stopped performing heavyweight work in socket/timer callbacks; reactor only queues add/remove/complete operations. (changes in src/http/http_client.cpp).
  • Updated default transports to use the async path by default while preserving compatibility with custom synchronous requesters: HttpJsonTransport and JsonRpcTransport now create and use a default async a2a::http::Client for streaming, falling back to the executor-worker compatibility path if a custom synchronous requester was injected. (changes in src/client/transport/http_json_transport.cpp, src/client/transport/json_rpc_transport.cpp, and headers).
  • Added conversion helpers between transport-local HttpRequest/HttpClientResponse and a2a::http::Request/Response for the bridge, and updated StartSseStream call sites to use the async client when available. (changes in src/client/transport/*).
  • Updated streaming documentation to state that observer callbacks are serialized per-stream on a shared dispatch executor and never run on the libcurl reactor thread. (change in docs/streaming-usage.md).

@MisterVVP MisterVVP added the codex Automatic label added by codex agent. Should not be used label Aug 29, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Aug 29, 2026
@MisterVVP MisterVVP added AI agent AI agent contribution performance Performance improvement related tasks based on benchmark results. Performance tests changes. and removed codex Automatic label added by codex agent. Should not be used labels Aug 29, 2026
@MisterVVP
MisterVVP marked this pull request as ready for review August 29, 2026 11:47
@MisterVVP
MisterVVP merged commit 73c3063 into dev-make-libcurl-streaming-cancellation-event-driven Aug 29, 2026
31 of 32 checks passed
@MisterVVP
MisterVVP deleted the dev-complete-async-shared-http-streaming branch August 29, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution 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