feat(ipc): add connection pool and subscription management#49
feat(ipc): add connection pool and subscription management#49EffortlessSteven wants to merge 2 commits intomainfrom
Conversation
- Add ClientConnectionPool with configurable min/max size, health checking, round-robin and least-loaded selection, and connection lifecycle management - Add KeepaliveConfig for configuring keepalive interval, timeout, and max missed pings - Add PoolMetrics with atomic counters for active/idle connections, failed health checks, and total requests - Extend SubscriptionManager with backpressure support - Add BackpressureStats for per-broadcast delivery/drop reporting - Add 20 new tests (15 connection pool + 5 subscription backpressure) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Review Summary by QodoAdd connection pool and subscription backpressure management
WalkthroughsDescription• Add ClientConnectionPool with configurable min/max size, health checking, and round-robin/least-loaded selection strategies • Implement KeepaliveConfig for connection keepalive management with interval, timeout, and max missed pings • Add PoolMetrics and PoolMetricsSnapshot for observable connection pool metrics (active, idle, failed checks, total requests) • Extend SubscriptionManager with backpressure support via subscribe_with_capacity(), broadcast_with_backpressure(), acknowledge(), and dropped_count() • Add BackpressureStats to report delivered vs dropped subscription IDs per broadcast • Add 20 comprehensive tests (15 for connection pool, 5 for subscription backpressure) Diagramflowchart LR
A["ClientConnectionPool"] -->|manages| B["PooledConnection"]
A -->|uses| C["KeepaliveConfig"]
A -->|tracks| D["PoolMetrics"]
A -->|applies| E["SelectionStrategy<br/>RoundRobin/LeastLoaded"]
F["SubscriptionManager"] -->|extends with| G["subscribe_with_capacity"]
F -->|broadcasts with| H["broadcast_with_backpressure"]
H -->|returns| I["BackpressureStats"]
F -->|manages| J["acknowledge<br/>dropped_count"]
File Changes1. crates/flight-ipc/src/connection_pool.rs
|
Code Review by Qodo
1. LeastLoaded misimplemented
|
| fn checkout_least_loaded(&self) -> Option<u64> { | ||
| self.connections | ||
| .iter() | ||
| .filter(|c| c.state == ConnState::Idle) | ||
| .min_by_key(|c| c.request_count) | ||
| .map(|c| c.id) | ||
| } |
There was a problem hiding this comment.
1. Leastloaded misimplemented 🐞 Bug ✓ Correctness
SelectionStrategy::LeastLoaded is documented as choosing the connection with the fewest in-flight requests, but it actually chooses the idle connection with the smallest cumulative request_count. This violates the strategy contract and will skew selection based on historical usage rather than current load.
Agent Prompt
### Issue description
`SelectionStrategy::LeastLoaded` is documented as selecting the connection with the fewest *in-flight* requests, but the implementation selects by cumulative `request_count` (total served) which never decreases. This violates the contract and produces unintuitive selection.
### Issue Context
- The pool currently only tracks `ConnState` and a monotonically increasing `request_count`.
- Least-loaded typically requires a separate `in_flight` counter or similar.
### Fix Focus Areas
- crates/flight-ipc/src/connection_pool.rs[262-277]
- crates/flight-ipc/src/connection_pool.rs[283-290]
- crates/flight-ipc/src/connection_pool.rs[364-428]
- crates/flight-ipc/src/connection_pool.rs[410-416]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Summary
Deepens the IPC layer with production-quality connection management and subscription patterns.
Changes
Connection Pool (connection_pool.rs)
Subscription Backpressure (subscriptions.rs)
Tests