ADR 0002 — Explicit wiring, no dependency-injection container

ADR 0002 — Explicit wiring, no dependency-injection container An architecture diagram generated by Archify. Explicit wiring, no container · typed Deps struct · main.go in dependency order · Architecture component Explicit wiring, no container typed Deps struct · main.go in dependency order module.Module · module.Validate · the manifest · Validate reports every violation at once · the mechanism module.Module · module.Validate the manifest · Validate reports every violation at once compose · apps/platformkit/modules.go · one Module(Deps{…}) call per module, in order · the mechanism compose · apps/platformkit/modules.go one Module(Deps{…}) call per module, in order app.New · the boot gates · Expand, Validate · three gates before it listens · the mechanism app.New · the boot gates Expand, Validate · three gates before it listens go build · scripts/check_imports.sh · compile error at the call site · contracts/ only · kept true by go build · scripts/check_imports.sh compile error at the call site · contracts/ only Rejected: uber/fx behind a descriptor · boot-time reflection errors, not call sites · Architecture component Rejected: uber/fx behind a descriptor boot-time reflection errors, not call sites the private application's registry · the same constructors · one fixed order slice · Architecture component the private application's registry the same constructors · one fixed order slice every module's Deps struct · what it cannot make for itself, as typed fields · Architecture component every module's Deps struct what it cannot make for itself, as typed fields made of written in run by checked by instead of Module(Deps) returns it hands its list to app.New the mechanism kept true by Legend Backend Database Security External

Context

  • • Before: uber/fx behind a 34-field module descriptor and eleven layers of materialization (~5,900 lines), 32 fx groups and 91 registry types
  • • Wiring errors surfaced at boot as reflection errors naming interfaces, not call sites; reading the graph meant running the program

Consequences

  • • The graph is readable top to bottom in one file and go build checks it; startup order is written down, so a cycle cannot be expressed
  • • main.go grows about one line per module, capped by the apps/ line ceiling; start and stop are method calls the kernel makes

Evidence

  • • grep -r 'go.uber.org/fx' go.mod prints nothing: the dependency does not exist
  • • scripts/check_imports.sh, last in make check; a wrong Deps field never reaches a test, go build refuses it first