djc / bb8

Full-featured async (tokio-based) postgres connection pool (like r2d2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for 'customizing' connections created by bb8::Pool

agersant opened this issue · comments

Hello and thank you for working on this crate!

I am in the process of migrating https://github.com/agersant/polaris to an async web framework. As part of this process, I am evaluating migrating from diesel + r2d2 to diesel + bb8 to interact with the SQLite database which power this app.

A feature that exists in r2d2 is the possibility to specify a ConnectionCustomizer which performs initialization work on every connection that a pool creates. For my use case, I set some SQLite PRAGMA configurations (journaling_mode, enable foreign keys, etc.) on every connection that comes out of the pool.

Could you consider adding a similar feature to bb8 pools?

Many thanks!

Yes, I think it would make sense to add this. Would you like to attempt to contribute this change?

(Polaris looks interesting, BTW. Does the Android client cache songs locally to limit bandwidth usage? Are you planning on an iOS client?)

Yeah I can try implementing this, although I'll probably have some questions on the way!

The Polaris client does cache songs locally, both to limit bandwidth usage and also to support playback in offline mode. No concrete plans for an iOS client by me at the moment. I have been thinking about rewriting the Android client with Flutter, which would be a step in the right direction.

If you have any questions, just ask here, I'm happy to answer them. Probably good to just start copying API from r2d2, except the functions return a Box.

As a side-note, my migration ran into a pretty serious roadblock 😭
overdrivenpotato/bb8-diesel#1