mule/runtime/watchman
The queue’s drain sentinel — a port of Oban.Queue.Watchman.
Erlang supervisors terminate children in reverse start order, so within
the one_for_all queue supervisor the watchman goes down FIRST, while the
producer and the running jobs are still alive. Its trapped parent exit is
the drain trigger: pause the producer (InitiateShutdown), wait up to
shutdown_grace_period for the running jobs to finish, emit
[:mule, :queue, :shutdown], then exit shutdown. The queue supervisor’s
child spec gives the watchman a shutdown timeout of grace + margin
(watchman.ex’s shutdown: shutdown + interval trick) so the supervisor
waits the drain out.
gleam_otp actors have no terminate callback; the trapped-exit message is
the substitute, exactly as in the producer and peer. The drain arrives on
a dedicated Subject(String) (Elixir’s raw {:drained, queue} send), so
the producer never imports this module’s message type.
Divergence (parity §9): elapsed is the real monotonic milliseconds
between the shutdown call and the drain/timeout — watchman.ex reports the
constant 0 on drain and the full grace period on timeout, even when the
drain took most of it.
Types
Values
pub fn start(
config config: config.Config,
queue queue: String,
) -> Result(
actor.Started(process.Subject(Message)),
actor.StartError,
)