Hello I'm using the bb8 package to create a Redis and Postgres pool. My issue is I don't understand how to effectively share the pool.
My current implementation uses Arc and passes down through the entire chain of functions to get where I need to use it, but that seems to have a lot of overhead for sharing something that isn't really changing.
I have a map of TCP connections that I need to be able to share among all threads. What I am imagining is a unsafe global map accessed with a mutex. I'm sure there's a safe way to do that, could you advise how?
As a word of advice, putting io resources in a Mutex almost always turns out to be a poor design. Typically it is better to spawn a task for each io resource, giving that task exclusive ownership of it, then "sharing" it by talking to the task.