Search⌘ K

Completing the Implementation of the Proctor Boundary Server

Now we will connect our proctor with our Mastery project. We'll start with the quiz session.

Our Proctor is a masterpiece, but we still have to wire it into the rest of Mastery. The boundary has two different points of integration. We will need to:

  • Revise the QuizManager to return the active sessions for a quiz.

  • Adapt QuizSession to end the sessions for a given title as our scheduler terminates them.

Those integrations should go quickly.

Returning active sessions

A big part of the battle of building concurrent systems is finding the processes to manage them. That’s the domain of the registry. To get the existing sessions with a given title, we will lean on our supervisor and the corresponding registry for our dynamic supervisor. We’ll open up /lib/mastery/boundary/quiz_session.ex and add this function to return active sessions:

C++
# /lib/mastery/boundary/quiz_session.ex
def active_sessions_for(quiz_title) do
Mastery.Supervisor.QuizSession
|> DynamicSupervisor.which_children |> Enum.filter(&child_pid?/1)
|> Enum.flat_map(&active_sessions(&1, quiz_title))
end
  • We start with the name of our supervisor, Mastery.Supervisor.QuizSession ...