Skip to main content

Module supervisor

Module supervisor 

Source
Expand description

The supervisor, and the one call site every action passes through.

§This module is the chokepoint

Every action this crate takes at the printer port is issued from Supervisor::issue_decided_action and from nowhere else, and that function records the policy decision for the request before it issues the call. That is structural rather than a convention, and two properties of this module are what make it so:

  1. No other item of this crate names an action method. A check over this crate’s own sources enumerates every syntactic reference to an action method of the printer port — a call, a path taken as a value, a function pointer, an alias — and refuses one outside that function.
  2. No item outside this module can obtain the handle to call one on. The printer handle is declared once, as a private field here, and the identifier PrinterPort appears nowhere else in this crate. Nothing hands it out: no function anywhere returns it.

The decision gates actions, not port traffic. Appending an event, writing its image, reading a snapshot, running a supervision turn and persisting its assessment are all port calls, none of them is an action anyone requested, and none of them takes a decision — the event append in particular is the first thing the loop does, before any decision could exist. What the policy stands between is a requested PrintAction and the printer.

The port’s reads — snapshot, job and the three reads of the files the printer holds — are outside the rule for that same reason, and are reached through Supervisor::read_snapshot, Supervisor::read_job, Supervisor::read_file_facts, Supervisor::read_printed_files and Supervisor::read_extruded_to.

§Nothing here sends a command string to a printer

There is no method on the printer port that admits one, and the only caller-supplied text that reaches the machine’s own file API is the FileName newtype, which refuses anything but a name.

Structs§

Issued
What became of one request that reached Supervisor::issue_decided_action.
RecoveryIssued
What became of one recovery request.
Supervisor
The supervision core: one printer, one store, one agent, one clock.