Juggernaut.Peer.Reload (Juggernaut v0.4.0)

Copy Markdown View Source

Hot loading in a warm worker after the sandbox was compiled again (design notes §10.9): the server's pool outlives a run, so before the next run's jobs every loaded module whose beam under the sandbox changed is loaded again.

For each such module, :code.soft_purge/1 first; if a process still runs the module's old code the worker must be recycled instead (nothing is loaded, the answer names the module). Otherwise the changed modules are loaded together, from their files, with :code.atomic_load/1. Call counting (Juggernaut.Peer.Footprint) is armed per loaded module, so it is disarmed after a reload and arms again on the next measured job.

Modules not loaded yet are left to the code server, which loads them from the sandbox on first use. This module runs inside workers and is never mutated.

Summary

Functions

Loads again every module loaded from under root (the sandbox) whose beam on disk differs from the loaded code. Returns {:ok, modules} (possibly empty) or {:recycle, reason}.

The loaded modules whose beam file under root differs from the loaded code.

Functions

run(root)

@spec run(Path.t()) :: {:ok, [module()]} | {:recycle, String.t()}

Loads again every module loaded from under root (the sandbox) whose beam on disk differs from the loaded code. Returns {:ok, modules} (possibly empty) or {:recycle, reason}.

stale(root)

@spec stale(Path.t()) :: [module()]

The loaded modules whose beam file under root differs from the loaded code.