Skip to content

feat: connection pooling - #60

Merged
bobrykov merged 3 commits into
masterfrom
feat/connection-pooling
Jul 22, 2026
Merged

feat: connection pooling#60
bobrykov merged 3 commits into
masterfrom
feat/connection-pooling

Conversation

@bobrykov

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c440623-d0aa-4297-89c7-9f768efbeab7

📥 Commits

Reviewing files that changed from the base of the PR and between 48fc429 and ebe4b95.

📒 Files selected for processing (1)
  • src/provider.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/provider.rs

📝 Walkthrough

Walkthrough

Provider builders now share HTTP client configuration, support injected reqwest::Client instances and optional pool/TCP settings, and use with_* method names. Internally built clients enable tcp_nodelay(true). Documentation, tests, examples, and changelog entries were updated.

Changes

Provider HTTP Configuration

Layer / File(s) Summary
Shared HTTP client configuration
src/provider.rs
Adds centralized client construction with timeout, pooling, TCP keepalive, conditional settings, client injection, and tcp_nodelay(true).
Provider builder integration
src/provider/anthropic.rs, src/provider/gemini.rs, src/provider/openai.rs
Provider builders delegate HTTP construction to HttpClientConfig and expose injection, timeout, pool, and TCP configuration methods.
Renamed builder API adoption
src/provider/..., examples/chat.rs
Provider wiring, documentation, examples, and tests use the renamed with_* consuming builder methods.
Release notes for public API changes
CHANGELOG.md
Documents HTTP client injection, renamed builder methods, TCP_NODELAY defaults, and the non-exhaustive stream::DeltaPart change.

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant ProviderBuilder
  participant HttpClientConfig
  participant ReqwestClient
  participant Provider
  Application->>ProviderBuilder: configure with_* options
  ProviderBuilder->>HttpClientConfig: pass HTTP settings or injected client
  HttpClientConfig->>ReqwestClient: reuse client or build configured client
  ReqwestClient->>Provider: provide HTTP transport
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and related to the main HTTP client pooling/configuration changes in this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/connection-pooling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/provider/anthropic.rs (1)

580-591: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Triplicated HTTP-client-injection/pool/TCP config across all three provider builders. The new http: Option<reqwest::Client> field, its four setters (http_client, pool_max_idle_per_host, pool_idle_timeout, tcp_keepalive), the tcp_nodelay default, the build() injection-vs-construct branch, and the full 5-test suite are copy-pasted verbatim across Anthropic, Gemini, and OpenAI builders. A shared helper (e.g. a HttpClientConfig struct with a build_http_client(self) -> Result<reqwest::Client, ApiError> method that each provider builder embeds/delegates to) would collapse this to one implementation and one test suite, so future knob additions need a single edit instead of three synchronized ones.

  • src/provider/anthropic.rs#L580-L591: extract this match self.http { ... } branch (plus the fields at L394-L425 and setters at L514-L566) into the shared helper.
  • src/provider/gemini.rs#L639-L650: replace this identical branch (plus fields at L451-L482 and setters at L577-L629) with a call into the same shared helper.
  • src/provider/openai.rs#L625-L636: replace this identical branch (plus fields at L452-L483 and setters at L560-L614) with a call into the same shared helper.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/provider/anthropic.rs` around lines 580 - 591, The HTTP client
configuration is duplicated across all provider builders. Extract the shared
client field, default, setters, and construction logic into one reusable helper
with a build method returning Result<reqwest::Client, ApiError>, then delegate
from the Anthropic builder at src/provider/anthropic.rs:580-591, Gemini builder
at src/provider/gemini.rs:639-650, and OpenAI builder at
src/provider/openai.rs:625-636; consolidate the duplicated five-test suite
alongside the helper and remove the provider-specific copies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/provider/anthropic.rs`:
- Around line 580-591: The HTTP client configuration is duplicated across all
provider builders. Extract the shared client field, default, setters, and
construction logic into one reusable helper with a build method returning
Result<reqwest::Client, ApiError>, then delegate from the Anthropic builder at
src/provider/anthropic.rs:580-591, Gemini builder at
src/provider/gemini.rs:639-650, and OpenAI builder at
src/provider/openai.rs:625-636; consolidate the duplicated five-test suite
alongside the helper and remove the provider-specific copies.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d9044b05-27de-477d-8eb8-cd9783c935cd

📥 Commits

Reviewing files that changed from the base of the PR and between 8c6221b and 4edb822.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • src/provider.rs
  • src/provider/anthropic.rs
  • src/provider/gemini.rs
  • src/provider/openai.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/provider.rs`:
- Around line 215-224: Update the rustdoc link in the client-building
documentation to reference the existing with_http_client method instead of the
nonexistent http_client symbol. Leave the surrounding behavior and documentation
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a76d81de-775c-461e-a918-357edc076969

📥 Commits

Reviewing files that changed from the base of the PR and between 4edb822 and 48fc429.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • examples/chat.rs
  • src/provider.rs
  • src/provider/anthropic.rs
  • src/provider/gemini.rs
  • src/provider/openai.rs

Comment thread src/provider.rs
@bobrykov
bobrykov merged commit 9074507 into master Jul 22, 2026
7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant