Skip to content

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:

  1. check the binary's module list and order it;
  2. turn a loaded Config into a component graph and a plan relative to the running configuration;
  3. build the components through the modules' factories, opening nothing;
  4. 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 / close

Files ​

FileContentsDocument
crates/kernel/src/modules.rsModules: checking and ordering the list, handing out factories and decodersModule order
crates/kernel/src/graph.rsGraph, Component: components, fingerprints, dependenciesComponent graph
crates/kernel/src/plan.rsPlanBetween: the plan between two graphsPlan
crates/kernel/src/instance.rsInstance: build, start, reload, closeInstance, Reload
crates/kernel/src/runtime.rsRuntime, Shard: a thread per CPURuntime and shards
crates/kernel/src/adapter.rsno_rule_sets, no_rules: stubs for builds without a router; no_dns is in crates/api/src/dns.rs and re-exportedInstance

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).

GPL-3.0-or-later