Skip to content

Conversation

@emcee21
Copy link

@emcee21 emcee21 commented Mar 19, 2025

No description provided.

@bikeshedder
Copy link
Collaborator

I superficially reviewed it and there is one thing that I really don't like about it:

Rather than adding new methods to the ManagerConfig and adding new fields to the ManagerConfig I would prefer if this was designed more like a plug-in. I'd like to see a ConfigProvider trait that can then be made as AWS specific as necessary:

e.g.

pub trait ConfigProvider {
    async fn get_config(&self) -> Config;
}

I'm really just sketching this in my head right now.

Maybe Config should be made a trait and BasicConfig and AwsConfig could then implement this new trait?

If connections need to be discarded after a given time that could be done via a pre_recycle hook.

@emcee21
Copy link
Author

emcee21 commented Mar 19, 2025 via email

@bikeshedder
Copy link
Collaborator

The max_age feature is something that can be of interest for every deadpool-* crate. There are some examples how to write that max age hook in the repo. It really needs some better documentation though.

emcee21 added 2 commits March 19, 2025 19:04
…g the first few characters of the token for tracing purposes.
…ers of the RDS token for improved traceability.
@bikeshedder bikeshedder added enhancement New feature or request A-postgres Area: PostgreSQL support / deadpool-postgres labels Mar 19, 2025
@bikeshedder
Copy link
Collaborator

Found the example:

Pool::builder(...)
    // ...
    .pre_recycle(Hook::sync_fn(|_, metrics| {
        if metrics.age() > max_age {
            Err(HookError::message("Max age reached"))
        } else {
            Ok(())
        }
    }))
    // ...

@bikeshedder
Copy link
Collaborator

It'd be nice if this felt more like a plugin. I've been toying with the idea of plugins some time ago. The API would then look like that:

Pool::builder(...)
    .add_plugin(MaxAge(Duration::from_seconds(300))

There are some unanswered questions though:

  • How does one change the configuration of a plugin?
  • How to add and remove plugins while the pool is running?
  • The order of plugins does matter! (Not a question but a finding while working on that idea)

Those were the reasons why I think making the entire pool hot swappable is the way to go in the future. This would allow maximum flexibility and enable basically every nice use case that I can think of.


The auth credentials are a bit different though. They don't require a pool reconfiguration and swapping of the manager. I can imagine some provider using OTPs that need to change for every single connection. So adding a way to dynamically create the configuration as needed makes a lot of sense.

@bikeshedder
Copy link
Collaborator

Sorry for using this PR as a rubber duck for my thoughts. I'll create a separate "meta" issue and update the milestones to reflect those ideas.

I understand that you need this feature asap and you don't want to maintain a separate branch for too long. Just give me a day or two to finally make up my mind on that topic. I really think it's time to improve this part for all deadpool-* crates once and for all.

@emcee21
Copy link
Author

emcee21 commented Mar 19, 2025 via email

@bikeshedder
Copy link
Collaborator

@bikeshedder bikeshedder force-pushed the main branch 3 times, most recently from 7a9da3d to f713c85 Compare September 2, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-postgres Area: PostgreSQL support / deadpool-postgres enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants