How to pass sqlx pool into services implementation? #1264
Answered
by
LucioFranco
mpiorowski
asked this question in
Q&A
-
How to pass postgress sqlx connection pool into services implementation? Is there some kind of Context like in Go? Would be rly greatfull for help. |
Beta Was this translation helpful? Give feedback.
Answered by
LucioFranco
Feb 13, 2023
Replies: 2 comments
-
You would place it in this struct https://github.com/hyperium/tonic/blob/master/examples/src/helloworld/server.rs#L11 and it will be available to each handler via the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mpiorowski
-
Thank You :) |
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
You would place it in this struct https://github.com/hyperium/tonic/blob/master/examples/src/helloworld/server.rs#L11 and it will be available to each handler via the
&self
. If you need to mutate it then you will need to figure out how to do that via aMutex
etc.