Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container interface {
Registrar
Resolver
OverrideService
ScopeManager
Names() []string
Close() error
}
type OverrideService ¶
type RegisterOption ¶
type RegisterOption func(option *RegisterOptions)
type RegisterOptions ¶
type RegisterOptions struct {
AlsoRegisterType bool
TypeRegistrationIsStrict bool
/* CollectionPriority orders this registration inside AllImplementing collections: a higher priority is collected earlier. Registrations sharing a priority keep the stable type-and-name order. */
CollectionPriority int
}
type Registrar ¶
type Registrar interface {
Register(serviceName string, provider any, options ...RegisterOption) error
MustRegister(serviceName string, provider any, options ...RegisterOption)
}
type Scope ¶
type Scope interface {
Resolver
OverrideService
Close() error
}
type ScopeManager ¶
type ScopeManager interface {
NewScope() Scope
}
type ServiceReference ¶ added in v3.12.0
ServiceReference identifies one registered service the way the container itself addresses it: by the name it was registered under, together with the canonical type of that registration. A type registered under several names yields one reference per name, so a consumer that collects services reaches every instance instead of failing on the ambiguity of the type alone.
type TypeLister ¶ added in v3.12.0
type TypeLister interface {
TypesImplementing(interfaceType reflect.Type) []reflect.Type
/* ReferencesImplementing lists every registration whose type satisfies the interface, one reference per registered name, ordered by descending collection priority and then by type and name so a collection never reorders between runs. */
ReferencesImplementing(interfaceType reflect.Type) []ServiceReference
}
TypeLister is implemented by a resolver that can enumerate the service types it holds. It stays apart from Resolver so that a resolver written outside the framework keeps working without it, and so a consumer that needs the capability has to ask for it explicitly.