-
I am setting up my stripe web server backend. My questions is as follows:
My question is for the stripe client, should I have 1 client per request (ie. initializing a Stripe client and then building the checkout), 1 client per connection (ie. each connection has their own Stripe Client), 1 per thread (each worker on the web server has a Stripe client that they use to generate checkout links), 1 per web server (this implies the stripe client is thread safe). Ideally I would hope it is 1 per web server so I can throw it behind a rust rocket fairing, but I wanted to check before I began development. Any guidance you could provide would be deeply appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you'd like multiple clients at once, you can just clone it. |
Beta Was this translation helpful? Give feedback.
Yep, we don't allow any
unsafe
code at all, so if the compiler lets you do it then you can.https://github.com/arlyon/async-stripe/blob/master/src/lib.rs#L57
Since rust is thread safe at the type level, then so is this library. Specifically:
move
it to that taskFor the purposes of rocket, you could for example create a
State
. Notice in the docs …