English
Kernel (ours-kernel)
crates/kernel is the microkernel. It knows no protocol, section or rule condition: all of that comes from the modules through the contract. The kernel's tasks:
- check the binary's module list and order it;
- turn a loaded
Configinto a component graph and a plan relative to the running configuration; - build the components through the modules' factories, opening nothing;
- start them on the shards and drive reload: what to rebuild, what to keep, how to hand over sockets and what to do with live connections.
text
LIST ──► Modules::new ──► Modules ──► decoders() ──► ours-native-config ──► Config
│ │
└──────────────► Instance::new(config) ◄───┘
│ build(): units → outbounds → rule-sets
│ → dns → rules → inbounds → Routing
▼
Runtime (shards) ◄── Instance::start / reload / closeFiles
| File | Contents | Document |
|---|---|---|
crates/kernel/src/modules.rs | Modules: checking and ordering the list, handing out factories and decoders | Module order |
crates/kernel/src/graph.rs | Graph, Component: components, fingerprints, dependencies | Component graph |
crates/kernel/src/plan.rs | PlanBetween: the plan between two graphs | Plan |
crates/kernel/src/instance.rs | Instance: build, start, reload, close | Instance, Reload |
crates/kernel/src/runtime.rs | Runtime, Shard: a thread per CPU | Runtime and shards |
crates/kernel/src/adapter.rs | no_rule_sets, no_rules: stubs for builds without a router; no_dns is in crates/api/src/dns.rs and re-exported | Instance |
Units and the service registry, through which stateful modules live across configurations — Units and services.
The types ComponentId, Plan, Change, ShardInfo, Handover themselves are declared in ours-api (crates/api/src/component.rs, plan.rs, shard.rs): modules see them too (the DNS module and units read the plan).
Kernel dependencies
ours-api, ours-config, ours-runtime and libraries (ours-bufpool, ours-codec, ours-json, ours-net-sys, ours-clock), plus tokio and tracing. Modules do not depend on the kernel; the kernel is called only from app/ (see Layers).