Closed forty1thousand closed 1 year ago
@forty1thousand actix uses a bunch of single-threaded tokio runtimes instead of a single multi-threaded to avoid overhead of work stealing, so many types are !Send
. Due to limitations in Rust type system we can't be transparent over Send
and Sync
, but here it actually should be ok to use SendWrapper
, which moves Send
check into a runtime.
See
@forty1thousand I'm closing this as @ilslv gave the working solution, which we do use in our production without problem. Feel free to re-open if there are further questions.
Is there an example of this being done somewhere
I have a project going where I need to store state inside of a session object and need to access it from inside of both a query and mutation resolver.
Here is a simple version of my current code.
graphql.rs
endpoints.rs
This code gives me a thread safety error when I run it.
I know the session store can also be accessed from a
HttpRequest
object but that also returns the same error.Is there a workaround or an example of this being done?