Laying Grounds for the Proctor Boundary Server
Let’s write some functions to handle our quizzes in our proctor.
Building the reply
Let’s talk about the reply:
-
It needs to set the state of the
GenServer
and set a timeout, so we’ll get control back for starting the next quiz. -
In this code, we’re going to make use of a little-used
GenServer
feature, appending an optional timeout to a:reply
tuple. -
When we’re done, our
:reply
tuple should look like{:reply, :ok, quizzes, timeout}
.
The timeout
is optional, so we’ll leave it off if the quizzes are empty.
Our code, then, returns any quizzes that have not yet been started and tacks on a timeout so that we’ll get control back in time to start the next quiz.
With the broad strokes coded, let’s see how we go about building that reply tuple. We’ll fill this in /lib/mastery/boundary/proctor.ex
:
Get hands-on with 1400+ tech skills courses.