feat(a2agrpc): add GRPCConnectionPool for gRPC client connection reuse (fixes #109) - #382
Open
kuangmi-bit wants to merge 2 commits into
Open
feat(a2agrpc): add GRPCConnectionPool for gRPC client connection reuse (fixes #109)#382kuangmi-bit wants to merge 2 commits into
kuangmi-bit wants to merge 2 commits into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Add a GRPCConnectionPool interface and a default in-memory implementation for reusing gRPC connections by URL. Background: grpc.NewClient creates a long-lived ClientConn with name resolution, TCP reconnection, and TLS handshake. Creating one per client (as the current WithGRPCTransport does) incurs unnecessary overhead. Changes: - GRPCConnectionPool interface: Acquire(+opts), Release - DefaultGRPCConnectionPool: in-memory pool with TTL eviction - WithPooledGRPCTransport: FactoryOption that acquires from the pool and releases on transport Destroy - 6 tests covering: acquire, reuse, multi-URL, TTL eviction, zero-TTL (no eviction), release semantics Design follows yarolegovich's proposal in a2aproject#109.
kuangmi-bit
force-pushed
the
feat/grpc-connection-pool
branch
from
July 22, 2026 22:01
b3afd90 to
e3776b9
Compare
Contributor
Author
|
@nahapetyan-serob — gentle ping on this one too. CI is all green (Go + ITK + PR title). This adds GRPCConnectionPool for gRPC client connection reuse (fixes #109). Each new connection currently pays the full TLS handshake cost — the pool amortizes this across calls. 34 tests, zero regressions. Would appreciate a review when you have time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
GRPCConnectionPoolinterface and a default in-memory implementation that enables gRPC connection reuse across client creations. Fixes #109.Problem
WithGRPCTransportcallsgrpc.NewClient(url, opts...)on every client creation. gRPCClientConnis designed to be long-lived — it handles name resolution, TCP reconnection with backoff, and TLS handshakes. Creating one per call is wasteful, especially for integration patterns like ADK RemoteAgent where the constructor opens a connection on every invocation.Solution
Adds two new exports to
a2agrpc/v1:1.
GRPCConnectionPoolinterface2.
DefaultGRPCConnectionPoolAn in-memory pool keyed by URL with configurable idle TTL. Zero/negative TTL disables eviction.
3.
WithPooledGRPCTransportA
FactoryOptionthat acquires from the pool and releases onDestroy():Design decisions
WithPooledGRPCTransport) not implicit — users opt inoptsatAcquiretime for consistency withWithGRPCTransportAcquireto avoid background goroutinesReleasedoes NOT close the connection — the pool owns the lifecycle