Search⌘ K
AI Features

Adding a Start Link

Explore how to add a start_link function that leverages the OTP dynamic supervisor to manage GenServer processes in Elixir. Learn to use via tuples for process registration and understand the importance of starting processes through supervisors to ensure robust lifecycle management.

Rather than starting our start_link directly, our code will use the dynamic supervisor to start the code for us.

Defining the start_link

We’ll add this code below the child_spec code in /lib/mastery/boundary/quiz_session.ex:

C++
def start_link({quiz, email}) do
GenServer.start_link(
__MODULE__,
{quiz, email},
name: via({quiz.title, email}))
end

The start_link itself looks exactly like we’d expect. It specifies the ...