I am pretty new to OTP. In trying to learn it I’m creating an application that does the following (high level overview):
- users submit X number tasks to a GenServer.
- The GenServer iterates over the queue of tasks and creates a process for each task.
- Once the process is completed it will notify the GenServer it’s done and return its value.
- Once the GenServer get’s notified it will update the state with the process’s return value, and notify the client with the updated state.
The diagram demonstrates what I’m trying to achieve.
I am able to spawn a process from the GenServer; however, I’m struggling to connect between the GenServer and process, so the process can call the GenServer; in return, the GenServer can
- Am I taking the right approach of calling a process from a GenServer? Is there better way to create process from GenServer and notify the process about the state?
- How do I call GenServer from a process and passing the state to server?