Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool: replacing closed connections #41

Closed
tanner0101 opened this issue Oct 18, 2019 · 2 comments
Closed

pool: replacing closed connections #41

tanner0101 opened this issue Oct 18, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@tanner0101
Copy link
Member

The connection pool currently replaces closed available connections by replacing them when they are requested. This means that once a pool's active connection count increases, it will never decrease.

It would be better to check the available connections list first for any open connections before attempting to open a new replacement.

@tanner0101 tanner0101 added the enhancement New feature or request label Oct 18, 2019
@MrMage
Copy link
Contributor

MrMage commented Oct 21, 2019

In case you are interested, here's my current thread-safe "resource pool" implementation with pruning. Working well in practice, but would need some adaptations for Vapor, of course: https://gist.github.com/MrMage/6fe071f405ac2c1b8a4cde25f05061db

Surprisingly, it is actually shorter than the Vapor one even though it supports pruning (mostly due to the lack of documentation, I guess).

@tanner0101
Copy link
Member Author

I ended up going with a while loop that I think will do the job: https://github.com/vapor/async-kit/blob/master/Sources/AsyncKit/ConnectionPool.swift#L214-L226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants