Add HTTPTransport setting to gremlin-go driver#3360
Add HTTPTransport setting to gremlin-go driver#3360milesbxf wants to merge 3 commits intoapache:masterfrom
Conversation
Allow users to provide a custom http.RoundTripper for Gremlin HTTP requests. This enables transport-level instrumentation (connection pool monitoring, request tracing via net/http/httptrace, metrics) without modifying driver internals. When HTTPTransport is set, the driver uses it directly and ignores pool-related settings (MaximumConcurrentConnections, MaxIdleConnections, etc.) since those configure the default transport. When nil, behaviour is unchanged — the driver creates its own http.Transport with the configured pool settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generated-by: Claude Code (claude-opus-4-6) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi @milesbxf, I did want to ask about which version you intend to target with your changes. If you're unfamiliar with our branching strategy, Gremlin-go looks very different under the hood in TinkerPop 4 ( |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3360 +/- ##
============================================
- Coverage 77.87% 75.49% -2.38%
+ Complexity 13578 13307 -271
============================================
Files 1015 1023 +8
Lines 59308 60260 +952
Branches 6835 7075 +240
============================================
- Hits 46184 45493 -691
- Misses 10817 12080 +1263
- Partials 2307 2687 +380 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
We'd like to be able to instrument the HTTP transport layer in gremlin-go, monitor connections and requests etc. Rather than add a specific metrics implementation that won't be useful to everyone, I'm proposing we make it possible for users to supply their own
http.RoundTripperso that they can hook into requests/responses and add custom logic. I think this is very Go idiomatic and opens up lots of other interesting use cases like more control over retries/client-side rate limits/logging/timeouts/testing.To make this possible, I've added an
HTTPTransport http.RoundTripperfield toClientSettingsandDriverRemoteConnectionSettings. When set, the driver uses it directly instead of creating its own transport. When nil, we fall back to the existing default behaviour.Open question: we expose a few HTTP transport dials directly on the DriverRemoteConnectionSettings (e.g.
MaxIdleConnections/IdleConnectionTimeout). If a user supplies their ownhttp.RoundTripperbut also configures these then what should happen? Currently we're just ignoring the specific configs and expecting that the user'sRoundTripperhas set sensible values, but I could see this being confusing. One possible alternative is a decorator pattern (something likeTransportDecorator func(http.RoundTripper) http.RoundTripper) that allows the user to wrap a basehttp.RoundTripperthat we supply with the pool configuration - that has some other complexities though.