#What it is
Vessel is the dependency injection container underneath Forge, extracted so it can be used on its own. Type-safe through generics, with real lifecycle management rather than just construction.
#What it does
- Constructor injection in the uber/dig style, with automatic resolution through ProvideConstructor.
- Typed service keys: ServiceKey[T] for compile-time safety and working autocomplete.
- Three lifetimes: singleton, transient and scoped, with scope context storage for request-specific data.
- Lifecycle: Start, Stop and Health on every registered service, which is what makes ordered startup and shutdown possible at the framework level.
- Lazy dependencies to defer expensive initialisation.
- Circular detection at registration rather than at first resolution.
- Middleware hooks on resolution and lifecycle events, for logging, metrics and validation.
- Service discovery: query and filter registered services by group or lifecycle.
- Sentinel errors, so failures are matchable with errors.Is.
#Why lifecycle belongs in the container
Most Go DI libraries construct objects and stop there. The genuinely hard part of a service is not construction, it is knowing that the database pool must be up before the migration runner, which must finish before the HTTP server accepts traffic, and that shutdown reverses all of it. Putting that in the container is what makes it inspectable.