Procyon|Docs
ComponentsResolving Components

Resolve Components

Resolve components manually from a container when constructor injection is not available.

Most application code should use constructor injection. Manual resolution is for boundary code: runners, adapters, framework integrations, and places where the runtime container is the API you receive.

runner.go
type ReportRunner struct {
	ctx runtime.Context
}

func NewReportRunner(ctx runtime.Context) *ReportRunner {
	return &ReportRunner{ctx: ctx}
}

Manual resolution usually follows this shape:

  1. Receive or access a runtime container.
  2. Resolve the component by type, name, or collection.
  3. Handle resolution errors explicitly.
  4. Use the resolved component at the boundary.
HelperUse it for
component.ResolveType[T](ctx, container)resolving one component by type
component.Resolve[T](ctx, container, name)resolving one named component as T
component.ResolveAll[T](ctx, container)resolving every component assignable to T
component.CanResolve(container, name)checking whether a name can resolve
component.CanResolveType[T](container)checking whether a type can resolve

Prefer constructor injection for regular services. Reach for these helpers when code lives at a runtime boundary.