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_constraints method to OptsBuilder to set pool_min and pool_max #368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Elcoid
Copy link

@Elcoid Elcoid commented Jan 23, 2024

Hello,

I added a method to OptsBuilder that sets pool_min and pool_max directly. This way, they can be set without having to instantiate a hashmap, then pass it to from_hash_map, then parse the strings in the map as integers. The method sets the two at the same time to ensure that pool_min <= pool_max (using a PoolConstraints).

This way, pool_min and/or pool_max can be set directly without having to
instanciate a hashmap and pass it to from_hash_map. The method sets the
two at the same time to ensure that pool_min <= pool_max (using a
PoolConstraints).
@blackbeam
Copy link
Owner

Hi. I don't really think it's a good idea to increase the API surface. Why don't you use OptsBuilder::pool_opts?

@Elcoid
Copy link
Author

Elcoid commented Jan 24, 2024

Hello,
Initially I searched for pool_min and pool_max in the sources, but the only thing I found was OptsBuilder::from_hash_map. That's why I thought an extra method would be good. However I just tried your suggestion and it works well (thanks for the idea). So I think my PR can be dismissed.

Here is what I ended up with, in case anyone else has the same problem as me:

let opts = OptsBuilder::new()
    /* [...] */
    .pool_opts(
        PoolOpts::default()
        .with_constraints(PoolConstraints::new(my_min, my_max).expect("Min is bigger than max!"))
    );

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.

2 participants