Binds a session subtree's lifetime to an owner process.
The provider form of ASM.query/3 starts a session, runs one prompt, and
stops the session from the caller's after block. An untrappable
Process.exit(caller, :kill) skips that block, and the supervised subtree
keeps running with its provider process group still attached. This guard
closes that window: it monitors the owner and terminates the subtree child
through ASM.Session.Supervisor.stop_session/2 when the owner goes down.
Two placement facts matter:
- stopping a session subtree is
ASM.Session.Serverstopping itself is not enough, becauseASM.Session.Subtreewould restart it; the subtree child itself has to be terminated - the guard therefore lives OUTSIDE the subtree it guards, under
ASM.Session.GuardSupervisor. A guard supervised by the subtree it is terminating would be shut down while blocked in that very call
The guard also monitors the subtree, so an ordinary ASM.stop_session/1
retires the guard instead of leaving it waiting on an owner forever.
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
@type state() :: %{ session_id: String.t(), supervisor: GenServer.server(), owner_ref: reference(), subtree_ref: reference() }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(keyword()) :: GenServer.on_start()