Replies: 1 comment
-
Hi~ I thought that these two cases are all ok. According to the existed practice about the It only wrapped the Hmmm... // let app_state = AppState {
// config: Arc<Config>,
// client: Arc<Client>,
//} If we want to share the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I struggle a bit with understanding the implications of Arc in Axum state handler. I would really appreciate it if anyone has the time to clarify what is best practice here.
Specifically, i’m unsure if its enough to have the entire struct in an arc, or i also should have the db client in a separate one.
Alt1:
Or if i should wrap every part in each own Arc?
Alt2:
How would axum actually handle the later case? I’ve understood it so that it automatically clones the struct in each handler, is that correct?
Will i in the later case be able to do
or do i need to explicitly clone the prisma_client here?
Generally i wonder what is the best practice, and the implications of each approach!
axum version
0.74
Beta Was this translation helpful? Give feedback.
All reactions