ComponentsRegistration
Register Constructors
Register constructors so Procyon can create application components.
Registration turns constructor functions into component definitions. A definition contains the component name, scope, return type, constructor metadata, and optional metadata.
package user
import "codnect.io/procyon/component"
func init() {
component.Register(NewUserRepository)
component.Register(NewUserService)
}During startup, Procyon loads registered definitions into the runtime container. The container then creates component instances and resolves constructor arguments from the dependency graph.
Registration flow
- Write a constructor.
- Register it with
component.Register. - Optionally customize the generated definition.
- Let the runtime container create the instance.
type UserService struct {
repo *UserRepository
}
func NewUserService(repo *UserRepository) *UserService {
return &UserService{repo: repo}
}Start with constructor shape, then configure names and scopes when the default definition is not enough.
