Skip to content

Share connections between stubs for the same target - #10

Merged
samuel-williams-shopify merged 4 commits into
socketry:mainfrom
ekmartin:ek-conductor/fix-issue-8
Sep 24, 2026
Merged

samuel-williams-shopify merged 4 commits into
socketry:mainfrom
ekmartin:ek-conductor/fix-issue-8

Conversation

@ekmartin

@ekmartin ekmartin commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Stubs and GAPIC adapters constructed without a channel override now share one Async::GRPC::Client per thread for the same target URL and TLS configuration, similar to grpc-core's global subchannel pool, so building a client per request or job reuses warm connections within a reactor. TLS configurations are copied, frozen, and compared by value using io-endpoint 0.19.0. Cache keys use the configuration directly, so different trust roots, client certificates, or verification policies never share a connection. Configuration inspection redacts private keys. Closing a stub leaves shared clients open; SharedChannel.close closes the current thread's shared clients, and grpc's grpc.use_local_subchannel_pool channel argument gives a stub its own client (which is also where ClientStub.endpoint_for overrides now apply). Fixes #8.

Validation against published io-endpoint 0.19.0 on Ruby 4.0.7: 139 tests, 486 assertions, 100% line coverage, bundle exec rubocop, and bake decode:index:coverage lib (36/36). Includes connection reuse, mutation isolation, and private-key redaction.

🤖 Generated with Claude Code

ekmartin and others added 4 commits September 25, 2026 11:12
Stubs constructed without a channel override now share one client per thread for the same URL and TLS configuration, similar to grpc-core's global subchannel pool. TLS configurations are copied and compared by value, and cache keys contain a digest rather than private keys. Closing a stub leaves shared clients open; `SharedChannel.close` closes the current thread's clients, and `grpc.use_local_subchannel_pool` gives a stub its own client.

Fixes socketry#8.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@samuel-williams-shopify
samuel-williams-shopify merged commit 5d104bd into socketry:main Sep 24, 2026
11 checks passed
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.

Share connections between stubs by default (per thread, per endpoint)

2 participants