Skip to content

Background tasks with access to rocket state (Specifically database conn) #1865

Answered by jebrosen
tehsmeely asked this question in Questions
Discussion options

You must be logged in to vote

I think this is essentially issue #1187.

rocket_sync_db_pools does not currently have this capability and I'm generally in agreement with @bubelov on adding your own secondary database pool given this limitation. It is likely possible to implement this, but it might necessitate even further redesign on top of the async compatibility work.

Instead, we focused efforts on direct support for async database pools (including deadpool-postgres and sqlx) in a new crate rocket_db_pools*. One of the goals for rocket_db_pools was to solve this exact limitation! The database type now implements Deref to the underlying pool type, so one could call SomeDb::fetch(&rocket).clone() to get an independent h…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tehsmeely
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants