English
Canonical form and reload
Code: crates/api/src/config.rs (Decoded, Blocks::cold, Part), crates/kernel/src/graph.rs, crates/kernel/src/plan.rs, crates/config/src/defaults.rs.
Reload compares neither texts nor YAML trees, but what the modules decoded. For that, every Decoded has a canonical form.
canonical
Decoded::new(value) computes canonical = value.encode() — the value written back by the codec the way Go's json.Marshal would write it (omitempty, the structure's field order). It has no positions. Consequences:
server: a.com:443andserver: a.com+ a port,[a]anda, a different key order in the text, comments — give the same form;- fields left empty are absent from the form; defaults (
ours_config::defaults) are applied by modules at build time, not at decoding — changing a default constant in the code does not change the form; - a variant block is wrapped in
{<variant>: ...}(variant_block), so thatws→grpcwith the same fields differ; - module conditions in rules are written "as written" (
Written::encode) and lifted to the other conditions (flat).
Blocks::canonical() is the object {block: form}; Blocks: PartialEq and Config: PartialEq compare forms.
cold and hot
Decoded::cold is the part of the form whose change requires recreating the component:
None— the whole form is cold;Some(Value::Null)— everything is applied in place (Decoded::hot());Blocks::cold()skips such a block entirely. This is how thereloadblock (ReloadPolicy) works: changing the policy rebuilds nothing;- another value — the module has singled out the hot part itself.
Components and the fingerprint
The kernel's graph (Graph::build) makes components out of Config:
| From | Component | Options for the fingerprint |
|---|---|---|
| inbound / outbound | Inbound/Outbound by name | {type, tag, blocks: Blocks::cold()} |
| endpoint | Outbound and Inbound by name | the same as inbound / outbound |
| a rule-set without parts | RuleSet | the same |
Decoded::parts of sections and rule-sets | the kind from Part::kind | {part: Part::cold, "<section>.<key>": ...} for Part::reads |
the log section | Log | canonical |
the route section (kernel) | Route | RouteOptions |
fingerprint is a hash of ours_json::to_string_pretty(options). The reload plan (plan.rs) compares the fingerprints of identical ComponentIds: equal — the component is kept, different — it is rebuilt, not there before — it is created, gone — it is closed. Several parts with one id (for example, two sections about one component) are merged into one array of options.
A section that did not describe parts gives no components: its change is seen only by whoever reads it (the module's unit through Build::section, Build::plan). reload and route give no parts; the graph adds route itself as the Route component.
Dependencies
The graph's edges come from references and defaults (see names and references): a component whose transitive dependency was added or changed, or whose set of dependencies changed, gets Change::DependencyChanged(reasons) in the plan. What to do with it is decided by the kernel; the module only honestly lists its references (References, #[config(reference = ...)]). A reference the module did not list will not get into the graph, and the dependent component will not learn about a rebuild.
An inbound's sockets
Separately from the fingerprint, the kernel decides whether a new inbound can take the old one's sockets (replaced_by in instance.rs). It does not read the canonical form for that: it compares what the inbounds report, Inbound::socket_identity and Inbound::udp_listener_fragmentation. A listening inbound builds its identity from ListenOptions::socket_identity (listen, listen_port, bind_interface, routing_mark, reuse_addr, netns).
ours_config::defaults
Constants with values for unset extension fields of this implementation: FAKEIP_FLUSH_INTERVAL_SECS, group probe parameters (GROUP_TEST_URL, GROUP_*, FALLBACK_RECOVERY_SUCCESSES), the xhttp/xmux parameters. They live in ours-config, next to the options, not in the modules that apply them: this way the value is the same for all consumers (for example, GROUP_IDLE_TIMEOUT_SECS is used by both group and the subscriptions module). They are not part of the canonical form and the fingerprint.
The plan, the graph and the hand-over of connections in detail — kernel.