Skip to content

Conversation

@adam-fowler
Copy link

@adam-fowler adam-fowler commented Dec 9, 2025

This PR fixes ConnectionPool.triggerForceShutdown() so that it actually shuts down the connection pool and the run() method returns.

I renamed the shutdown connection pool action to initiateShutdown and added a new action shutdown. The initiateShutdown action will close all the connections and related timers and is returned by triggerForceShutdown. The shutdown action will finish the eventStream thus allowing the run method to return. The connectionClosed method will return the shutdown action once the connections array is empty. There is also support for dealing with connections that are established after triggerForceShutdown is called which wasn't there before.

I have also added tests for the state machine, for when connections are idle, leased or a connection request is in process. And a single ConnectionPool test that checks triggerForceShutdown actually causes the run method to return.

Ensure ConnectionPool.triggerForceShutdown works and that it doesn't shutdown until all connections are closed

@adam-fowler adam-fowler changed the title Ensure ConnectionPool .triggerForceShutdown() works and that it doesn't shutdown until all connections are closed Ensure ConnectionPool.triggerForceShutdown() works and that it doesn't shutdown until all connections are closed Dec 9, 2025
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 86.58537% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.63%. Comparing base (9217854) to head (9badd98).

Files with missing lines Patch % Lines
...ources/ConnectionPoolModule/PoolStateMachine.swift 76.19% 10 Missing ⚠️
...nPoolModule/PoolStateMachine+ConnectionGroup.swift 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #607      +/-   ##
==========================================
- Coverage   75.68%   75.63%   -0.06%     
==========================================
  Files         134      134              
  Lines        9912     9972      +60     
==========================================
+ Hits         7502     7542      +40     
- Misses       2410     2430      +20     
Files with missing lines Coverage Δ
Sources/ConnectionPoolModule/ConnectionPool.swift 94.88% <100.00%> (+0.07%) ⬆️
...nPoolModule/PoolStateMachine+ConnectionState.swift 86.60% <100.00%> (ø)
...nPoolModule/PoolStateMachine+ConnectionGroup.swift 89.91% <97.05%> (+1.06%) ⬆️
...ources/ConnectionPoolModule/PoolStateMachine.swift 86.47% <76.19%> (-2.50%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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