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

Add Pool::add #214

Merged
merged 3 commits into from
Aug 28, 2024
Merged

Add Pool::add #214

merged 3 commits into from
Aug 28, 2024

Conversation

tneely
Copy link
Contributor

@tneely tneely commented Jul 27, 2024

Fixes #212

This adds Pool::add, which allows for externally created connections to be added and managed by the pool. If the pool is at maximum capacity when this method is called, it will return the input connection as part of the Err response.

I considered allowing Pool:add to ignore max_size when adding to the pool, but felt it could lead to confusion if the pool is allowed to exceed its capacity in this specific case.

This change required making PoolInternals::approvals visible within the crate to get the approval needed to add a new connection. The alternative would have required defining a new pub(crate) method for this specific use case, which feels worse. I'm open to suggestions on how to more cleanly integrate this change into the package.

bb8/src/inner.rs Outdated Show resolved Hide resolved
bb8/src/inner.rs Outdated Show resolved Hide resolved
@tneely
Copy link
Contributor Author

tneely commented Aug 13, 2024

Sorry for the delay - I lost track of this PR at some point. I've moved a few things around based on your feedback and also added an AddError enum to differentiate between when the connection is broken and when there's no capacity.

Copy link
Owner

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good, some small suggestions left!

bb8/src/api.rs Outdated Show resolved Hide resolved
bb8/src/api.rs Show resolved Hide resolved
Copy link
Owner

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly looks good, needs one tweak to the commit history. Also, some formatting to fix (see CI).

bb8/tests/test.rs Outdated Show resolved Hide resolved
@tneely tneely force-pushed the pool/add branch 2 times, most recently from 551915e to bfe868e Compare August 28, 2024 02:30
djc and others added 2 commits August 28, 2024 11:07
Fixes djc#212

This adds `Pool::add`, which allows for externally created
connections to be added and managed by the pool. If the pool
is at maximum capacity when this method is called, it will
return the input connection as part of the Err response.

I considered allowing `Pool:add` to ignore `max_size` when
adding to the pool, but felt it could lead to confusion if
the pool is allowed to exceed its capacity in this specific
case.

This change required making PoolInternals::approvals visible
within the crate to get the approval needed to add a new
connection. The alternative would have required defining a
new pub(crate) method for this specific use case, which feels
worse. I'm open to suggestions on how to more cleanly integrate
this change into the package.
@djc djc merged commit 165ca59 into djc:main Aug 28, 2024
7 of 8 checks passed
@djc
Copy link
Owner

djc commented Aug 28, 2024

Thanks for your patience through a number of iterations!

@tneely
Copy link
Contributor Author

tneely commented Aug 29, 2024

You're welcome, thanks for working through the PR with me!

@tneely tneely deleted the pool/add branch August 29, 2024 02:42
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.

[feature] Add/Get New Pooled Connections
2 participants