Skip to content

How to pass sqlx pool into services implementation? #1264

Answered by LucioFranco
mpiorowski asked this question in Q&A
Discussion options

You must be logged in to vote

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 a Mutex etc.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mpiorowski
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
Category
Q&A
Labels
None yet
2 participants