XRAPH/Work/Dependency injection
Go · since 2026

Vessel

The DI container underneath Forge, extracted so it can be used on its own. Generic type-safe resolution, uber/dig-style constructor injection, singleton, transient and request-scoped lifetimes, circular-dependency detection, and Start/Stop/Health on every registered service.

Language
Go
Category
Dependency injection
Since
2026
Stars
0
Repository
01

Anatomy

4 modules
01

Resolution

Constructor injection with typed service keys.

02

Lifetimes

Singleton, scoped and transient, chosen at registration.

03

Lifecycle

Start and stop hooks ordered by the dependency graph.

04

Discovery

Service lookup with sentinel errors rather than panics.

02

Why it exists

Design notes

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

03

Signals

GitHub
Stars
0
Language
Go
Since
2026
Adopters
00

Shipping something on Vessel? Nobody is listed here yet. Tell me what you built and you will be the first.

Get listed