English
Plan
Plan and Change are declared in crates/api/src/plan.rs, the computation is PlanBetween::between in crates/kernel/src/plan.rs.
The plan is what reload does with every component when moving from the graph old to the graph new:
rust
pub enum Change {
Added,
Removed,
Updated, // the fingerprint changed
DependencyChanged(BTreeSet<ComponentId>), // own options are the same, something it depends on changed
}
pub struct Plan {
pub changes: BTreeMap<ComponentId, Change>,
pub unchanged: BTreeSet<ComponentId>,
}Algorithm
A component exists only in
new—Added; exists in both with a differentfingerprint—Updated.Exists only in
old—Removed.For the remaining components of
new, the reasons forDependencyChanged:- the symmetric difference of direct dependencies in
oldandnew(a reference started pointing to another component, or the "default" changed); - transitive dependencies in
newmarkedAddedorUpdated.
No reasons — the component goes to
unchanged.- the symmetric difference of direct dependencies in
A Removed dependency does not become a reason on its own: a component that referred to a removed one is caught by the edge difference.
Who reads the plan
Instance::build(crates/kernel/src/instance.rs) takes ready objects from the running configuration for the ids inplan.unchanged: outbounds, rule-sets, rules (route), inbounds. Everything else is built anew.- The DNS factory gets the plan and the previous
Dnsand decides itself what to reuse (DnsFactory,crates/api/src/module.rs). - Units get the plan in
Build::plan(for example,ntpreuses the running client,Ntp::reusable). check --diffprints the plan (app/ours/src/diff.rs) — see Reload.Reloaded::planis returned fromInstance::reload; the binary logs the number of changed components.
The first configuration is built with an empty plan (Plan::default()), Build::reload == false.