Coming from go, so I am highly confused about how things must be structured in rust.
Let’s say I have structs: Database, Network and Proc.
Network must receive external messages via TCP, the library is using tokio so I guess I will need to run a tokio runtime in a separate thread. It forwards external messages and receives messages back from proc.
Proc runs a loop to process several types of messages just like a goroutine with select and several channels. No tokio here, just 1 thread with message match in a loop. Some messages will be sent by Network struct. Proc also broadcasts some data via Network struct.
As to Database, both Network and Proc should be able to use it.
The library for networking is based on tokio but Network must be a trait and have few implementations using other libs without tokio.
So the question is how do I connect all these “servers” in order to be able to send messages to each other and use each other functions. I spent a lot of time on it already, went into a Mutex hell, Arcs, Weaks, dyn Traits, etc. Hands down, I need best practices.
Perhaps there is some small open source project to learn from or a set of patterns?