Start Per-User Processes with a Dynamic Supervisor
Now we need to start a process per user. Since we don’t have a fixed number of processes to start, and since we’ll also need to be able to look them up based on a user’s attributes, we will need a structure that is a little more sophisticated. We will use a dynamic supervisor.
Most supervisors create processes when an application starts or restarts. That’s normally what you want, but not always. A dynamic supervisor is a supervisor that starts children dynamically. Since we have no way of knowing who will take quizzes and when, that sounds like exactly what we need. To use a dynamic supervisor, you need many of the same pieces of information:
-
You must provide a child spec, the description for ...
Get Designing Elixir Systems With OTP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.