Creating a start_link
Let’s breathe life into our QuizManager GenServer by starting a process.
We'll cover the following
Role of our application
The primary role of the application will be to provide the following for the boundary layer:
-
Packaging structure
-
Lifecycle support
Here’s how it will work.
When our application starts via Application.start
, that function doesn’t call our boundary’s start links directly. Instead, it will call our supervisor’s start_link
, and that process will start and monitor our application’s main processes.
Starting up the quiz manager
Let’s set up our application to start our QuizManager
whenever we start it via mix
. That should be pretty easy to do since we need only start a single copy of our application. When the supervisor starts, it will call the start_link
of the boundary layer. Let’s set that up now. We’ll open up /lib/mastery/boundary/quiz_manager.ex
and add this start_link
callback right below the init
callback, like this:
Get hands-on with 1200+ tech skills courses.