Skip to content

Add MaxConnectionLifetime to Go GLV (3.7 WebSocket driver)#10

Open
jayanthKiddom wants to merge 1 commit into3.7-devfrom
jv.go-conn-lifetime-3.7
Open

Add MaxConnectionLifetime to Go GLV (3.7 WebSocket driver)#10
jayanthKiddom wants to merge 1 commit into3.7-devfrom
jv.go-conn-lifetime-3.7

Conversation

@jayanthKiddom
Copy link

Summary

  • Adds MaxConnectionLifetime time.Duration to ClientSettings and DriverRemoteConnectionSettings
  • When set, loadBalancingPool.getLeastUsedConnection() checks connection age on each write: expired idle connections are closed immediately; expired connections with in-flight requests are drained (kept alive but not selected for new work) and a new connection is created as capacity allows
  • Disabled by default (0 = connections live forever), so there is no behavior change for existing users
  • CreatedAt field added to connection struct; isExpired() helper method added

Test plan

  • TestConnectionIsExpired — verifies isExpired() returns false when disabled (0), false within lifetime, true after lifetime
  • TestExpiredIdleConnectionClosed — expired + idle connection is closed and removed from pool
  • TestExpiredBusyConnectionKeptButNotSelected — expired + busy connection is retained but a fresh connection is selected instead
  • TestMaxConnectionLifetimeClientSettingsWiring — field on ClientSettings flows into loadBalancingPool
  • TestMaxConnectionLifetimeDefaultIsZero — default value is 0 (disabled)
  • TestMaxConnectionLifetimeDriverRemoteConnectionSettingsWiring — field on DriverRemoteConnectionSettings flows into loadBalancingPool
  • All existing pool tests updated to pass 0 for the new maxConnLifetime parameter

🤖 Generated with Claude Code

Adds a MaxConnectionLifetime setting to ClientSettings and
DriverRemoteConnectionSettings. When set, the loadBalancingPool
checks connection age on each write: expired idle connections are
closed immediately; expired connections with in-flight requests are
drained (kept alive but not selected for new work) and a replacement
is created as capacity allows. Disabled by default (0).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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